Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ class ConfigTest extends DDSpecification {
def "otel generic config via system properties - metrics enabled"() {
setup:
System.setProperty(DD_METRICS_OTEL_ENABLED_PROP, "true")
System.setProperty(OTEL_RESOURCE_ATTRIBUTES_PROP, "service.name=my=app,service.version=1.0.0,deployment.environment=production, message=blahblah")
System.setProperty(OTEL_RESOURCE_ATTRIBUTES_PROP, "service.name=my=app,service.version=1.0.0,deployment.environment.name=production, message=blahblah")
Comment thread
tylfin marked this conversation as resolved.
System.setProperty("otel.log.level", "warning")

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class OtelEnvironmentConfigSourceTest extends DDSpecification {
'key4=four,' +
'key5=five,' +
'key6=six,' +
'deployment.environment=staging,' +
'deployment.environment.name=staging,' +
'key7=seven,' +
'key8=eight,' +
'key9=nine,' +
Expand Down Expand Up @@ -374,4 +374,23 @@ class OtelEnvironmentConfigSourceTest extends DDSpecification {
// only the first 10 custom attributes are mapped to tags
source.get(TAGS) == 'key1:one,key2:two,key3:three,key4:four,key5:five,key6:six,key7:seven,key8:eight,key9:nine,key10:ten'
}

def "named deployment environment takes precedence over legacy attribute"() {
setup:
injectSysConfig('dd.trace.otel.enabled', 'true', false)
injectSysConfig('otel.resource.attributes', resourceAttributes, false)

when:
def source = new OtelEnvironmentConfigSource()

then:
source.get(ENV) == 'production'
source.get(TAGS) == null

where:
resourceAttributes << [
'deployment.environment.name=production,deployment.environment=staging',
'deployment.environment=staging,deployment.environment.name=production'
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ private void setupOtelEnvironment() {
Map<String, String> attributeMap = parseOtelMap(resourceAttributes);
capture(SERVICE_NAME, attributeMap.remove("service.name"));
capture(VERSION, attributeMap.remove("service.version"));
capture(ENV, attributeMap.remove("deployment.environment"));
String environment = attributeMap.remove("deployment.environment");
String namedEnvironment = attributeMap.remove("deployment.environment.name");
capture(ENV, namedEnvironment != null ? namedEnvironment : environment);
capture(TAGS, renderDatadogMap(attributeMap, 10));
}
capture(LOG_LEVEL, logLevel);
Expand Down