Class OpenTelemetryResourceAttributes
java.lang.Object
org.springframework.boot.opentelemetry.autoconfigure.OpenTelemetryResourceAttributes
OpenTelemetryResourceAttributes retrieves information from the
OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME environment variables
and merges it with the resource attributes provided by the user. User-provided resource
attributes take precedence. Additionally, spring.application.* related
properties can be applied as defaults.
- Since:
- 4.0.0
- Author:
- Dmytro Nosan
-
Constructor Summary
ConstructorsConstructorDescriptionOpenTelemetryResourceAttributes(Environment environment, @Nullable Map<String, String> resourceAttributes) Creates a new instance ofOpenTelemetryResourceAttributes. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTo(BiConsumer<String, String> consumer) Applies resource attributes to the providedBiConsumerafter being combined from environment variables and user-defined resource attributes.
-
Constructor Details
-
OpenTelemetryResourceAttributes
public OpenTelemetryResourceAttributes(Environment environment, @Nullable Map<String, String> resourceAttributes) Creates a new instance ofOpenTelemetryResourceAttributes.- Parameters:
environment- the environmentresourceAttributes- user-provided resource attributes to be used
-
-
Method Details
-
applyTo
Applies resource attributes to the providedBiConsumerafter being combined from environment variables and user-defined resource attributes.If a key exists in both environment variables and user-defined resources, the value from the user-defined resource takes precedence, even if it is empty.
Additionally,
spring.application.nameorunknown_servicewill be used as the default forservice.name, andspring.application.groupwill serve as the default forservice.groupandservice.namespace.- Parameters:
consumer- theBiConsumerto apply
-