-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed as duplicate of#43712
Labels
status: duplicateA duplicate of another issueA duplicate of another issue
Description
According to the OpenTelemetry specification (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable), OTEL_RESOURCE_ATTRIBUTES must always be merged with the user-provided attributes.
Currently, OtlpMetricsPropertiesConfigAdapter uses the user's attributes if they are provided; otherwise, it falls back to the attributes from OTEL_RESOURCE_ATTRIBUTES.
As I understand it, the logic should be:
public Map<String, String> resourceAttributes() {
// OTEL_RESOURCE_ATTRIBUTES
Map<String, String> result = new LinkedHashMap<>(OtlpConfig.super.resourceAttributes());
//merge with user's attributes
Map<String, String> resourceAttributes = this.openTelemetryProperties.getResourceAttributes();
if (!CollectionUtils.isEmpty(resourceAttributes)) {
result.putAll(resourceAttributes);
}
else if (this.properties.getResourceAttributes() != null) {
result.putAll(this.properties.getResourceAttributes());
}
result.computeIfAbsent("service.name", (key) -> getApplicationName());
result.computeIfAbsent("service.group", (key) -> getApplicationGroup());
return Collections.unmodifiableMap(result);
}Metadata
Metadata
Assignees
Labels
status: duplicateA duplicate of another issueA duplicate of another issue