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"
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 opentelemetry-sdk library
-
Maven projects
<!-- https://mvnrepository.com/artifact/io.opentelemetry/opentelemetry-sdk -->
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.11.0</version>
</dependency>
-
Gradle projects
dependencies {
compile 'io.opentelemetry:opentelemetry-sdk:1.11.0'
}
Step 2 - Import dependencies in the application Java class file
import io.opentelemetry.api.trace.Span;
Step 3 - Add custom tag into Span
Span currentSpan = Span.current();
currentSpan.setAttribute("foo","bar");