SDK configuration
You are viewing the English version of this page because it has not yet been fully translated. Interested in helping out? See Contributing.
This spring starter supports configuration metadata, which means that you can see and autocomplete all available properties in your IDE.
General configuration
The OpenTelemetry Starter supports all the SDK Autoconfiguration (since 2.2.0).
You can update the configuration with properties in the application.properties
or the application.yaml file, or with environment variables.
application.yaml example:
otel:
propagators:
- tracecontext
- b3
resource:
attributes:
deployment.environment: dev
service:
name: cart
namespace: shop
Environment variables example:
export OTEL_PROPAGATORS="tracecontext,b3"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=dev,service.name=cart,service.namespace=shop"
SDK-level settings (resources, propagators, exporters) use the standard
declarative configuration schema
directly in application.yaml. System properties and environment variables
still work to override values — see
Environment variable overrides.
otel:
file_format: '1.0'
resource:
attributes:
- name: deployment.environment
value: dev
- name: service.name
value: cart
- name: service.namespace
value: shop
propagator:
composite:
- tracecontext:
- b3:
Overriding Resource Attributes
As usual in Spring Boot, you can override properties in the
application.properties and application.yaml files with environment
variables.
For example, you can set or override the deployment.environment resource
attribute (not changing service.name or service.namespace) by setting the
standard OTEL_RESOURCE_ATTRIBUTES environment variable:
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=prod"
Alternatively, you can use the OTEL_RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT
environment variable to set or override a single resource attribute:
export OTEL_RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT="prod"
The second option supports SpEL expressions.
Note that DEPLOYMENT_ENVIRONMENT gets converted to deployment.environment by
Spring Boot’s
Relaxed Binding.
Disable the OpenTelemetry Starter
Set otel.sdk.disabled to true to disable the starter, e.g. for testing
purposes:
otel:
sdk:
disabled: true
Set otel.disabled to true to disable the starter, e.g. for testing purposes.
Note: with declarative configuration, the
property name is otel.disabled, not otel.sdk.disabled.
otel:
file_format: '1.0'
disabled: true
Programmatic configuration
See Programmatic configuration.
Resource Providers
The OpenTelemetry Starter includes the same resource providers as the Java agent:
In addition, the OpenTelemetry Starter includes the following Spring Boot specific resource providers:
Distribution Resource Provider
FQN:
io.opentelemetry.instrumentation.spring.autoconfigure.resources.DistroVersionResourceProvider
| Attribute | Value |
|---|---|
telemetry.distro.name | opentelemetry-spring-boot-starter |
telemetry.distro.version | version of the starter |
Spring Resource Provider
FQN:
io.opentelemetry.instrumentation.spring.autoconfigure.resources.SpringResourceProvider
| Attribute | Value |
|---|---|
service.name | spring.application.name or build.name from build-info.properties (see Service name) |
service.version | build.version from build-info.properties |
With declarative configuration, resource
providers are configured explicitly as detectors under
resource.detection/development.detectors. Only listed detectors are active —
nothing is auto-discovered via SPI.
otel:
resource:
detection/development:
detectors:
- container: # container.id
- host: # host.name, host.arch
- host_id: # host.id
- os: # os.type, os.description
- process: # process.pid, process.executable.path, process.command_line
- process_runtime: # process.runtime.name/version/description
- service: # service.name, service.instance.id
- spring: # service.name (from spring.application.name), service.version (from build-info)
The telemetry.distro.name and telemetry.distro.version attributes are always
added automatically by the starter for troubleshooting purposes.
Service name
Using these resource providers, the service name is determined by the following precedence rules, in accordance with the OpenTelemetry specification:
otel.service.namespring property orOTEL_SERVICE_NAMEenvironment variable (highest precedence)service.nameinotel.resource.attributessystem/spring property orOTEL_RESOURCE_ATTRIBUTESenvironment variablespring.application.namespring propertybuild-info.propertiesImplementation-Titlefrom META-INF/MANIFEST.MF- The default value is
unknown_service:java(lowest precedence)
The service name depends on which resource detectors you include (see Resource Providers):
service.nameinotel.resource.attributes(highest precedence):otel: resource: attributes: - name: service.name value: my-spring-appThe
servicedetector — if included, auto-detects fromOTEL_SERVICE_NAME:otel: resource: detection/development: detectors: - service:The
springdetector — if included, detects fromspring.application.nameandbuild-info.properties:otel: resource: detection/development: detectors: - spring:The default value is
unknown_service:java(lowest precedence)
Use the following snippet in your pom.xml file to generate the
build-info.properties file:
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
springBoot {
buildInfo {
}
}
Feedback
Was this page helpful?
Thank you. Your feedback is appreciated!
Please let us know how we can improve this page. Your feedback is appreciated!