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 @@ -340,8 +340,7 @@ class OtelEnvironmentConfigSourceTest extends DDSpecification {
source.get(SERVICE_NAME) == 'DEV_SERVICE'
source.get(ENV) == 'staging'
source.get(VERSION) == '42'
// 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'
source.get(TAGS) == 'key1:one,key2:two,key3:three,key4:four,key5:five,key6:six,key7:seven,key8:eight,key9:nine,key10:ten,key11:eleven,key12:twelve'
}

def "otel resource attributes environment variable is mapped"() {
Expand Down Expand Up @@ -371,8 +370,7 @@ class OtelEnvironmentConfigSourceTest extends DDSpecification {
source.get(SERVICE_NAME) == 'DEV_SERVICE'
source.get(ENV) == 'staging'
source.get(VERSION) == '42'
// 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'
source.get(TAGS) == 'key1:one,key2:two,key3:three,key4:four,key5:five,key6:six,key7:seven,key8:eight,key9:nine,key10:ten,key11:eleven,key12:twelve'
}

def "named deployment environment takes precedence over legacy attribute"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private void setupOtelEnvironment() {
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(TAGS, renderDatadogMap(attributeMap));
Comment thread
mcculls marked this conversation as resolved.
}
capture(LOG_LEVEL, logLevel);
capture(SERVICE_NAME, serviceName);
Expand Down Expand Up @@ -469,15 +469,11 @@ private static Map<String, String> parseOtelMap(String value) {
}

/** Renders the map as a comma-separated list of key:value entries. */
private static String renderDatadogMap(Map<String, String> map, int maxEntries) {
private static String renderDatadogMap(Map<String, String> map) {
StringBuilder buf = new StringBuilder();

int entries = 0;
for (Map.Entry<String, String> entry : map.entrySet()) {
buf.append(entry.getKey()).append(':').append(entry.getValue()).append(',');
if (++entries >= maxEntries) {
break;
}
}

// remove trailing comma, mapping empty conversion to null
Expand Down
Loading