Skip to main content

Custom tags configuration

Custom tags configuration via startup parameter

You can use OTEL_RESOURCE_ATTRIBUTES= startup parameter to pass a custom static tag to all spans generated in the service. For example:

OTEL_RESOURCE_ATTRIBUTES="service.name=Accounts"
OTEL_RESOURCE_ATTRIBUTES="application=OnlineBanking,exampleKey=exampleValue"

Add the deployment.environment=[environment-name] tag as needed to allow for filtering by environment on dashboard panels. For more information, see Services Dashboard Panels.

Custom tags configuration through your code

If the default tags are not providing enough relevant data you can add custom tags or attributes into spans. Follow these steps:

Step 1: Satisfy project dependencies

Add the opentelemetry-sdk library.

  • Maven projects

    <!-- https://mvnrepository.com/artifact/io.opentelemetry/opentelemetry-sdk -->
    <dependency>
    <groupId>io.opentelemetry</groupId>
    <artifactId>opentelemetry-sdk</artifactId>
    <version>1.32.0</version>
    </dependency>
  • Gradle projects

    dependencies {
    compile 'io.opentelemetry:opentelemetry-sdk:1.32.0'
    }

Step 2: Import dependencies

Import dependencies in the application Java class file:

import io.opentelemetry.api.trace.Span;

Step 3: Add custom tag into Span

Use the following to add a custom tag:

Span currentSpan = Span.current();
currentSpan.setAttribute("foo","bar");
Status
Legal
Privacy Statement
Terms of Use

Copyright © 2024 by Sumo Logic, Inc.