Skip to content

Commit 5136c2e

Browse files
committed
normalize key
1 parent 378301e commit 5136c2e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

internal-api/src/main/java/datadog/trace/api/ProcessTags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private static void parseMappingEntry(
9696
"No value for key '{}' from source '{}' in process.tags.mapping", configKey, source);
9797
return;
9898
}
99-
tags.put(processTagKey, value);
99+
tags.put(TraceUtils.normalizeTagValue(processTagKey), value);
100100
}
101101

102102
private static void fillJeeTags(SortedMap<String, String> tags) {

internal-api/src/test/groovy/datadog/trace/api/ProcessTagsForkedTest.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@ class ProcessTagsForkedTest extends DDSpecification {
249249
System.clearProperty("prop.b")
250250
}
251251
252+
def 'should normalize mapped process tag key'() {
253+
setup:
254+
System.setProperty("my.prop", "some_value")
255+
injectSysConfig("process.tags.mapping", "{prop}my.prop:1Tenant")
256+
ProcessTags.reset()
257+
when:
258+
def tags = ProcessTags.getTagsAsStringList()
259+
then:
260+
// key '1Tenant' is valid (leading digit is allowed) but the colon in raw keys would be invalid;
261+
// normalizeTagValue strips leading non-alphanumeric chars and replaces colons — verify the key is stored normalized
262+
tags.any { it.startsWith("1tenant:") }
263+
!tags.any { it.startsWith("1Tenant:") }
264+
cleanup:
265+
System.clearProperty("my.prop")
266+
}
267+
252268
def 'process tag value normalization'() {
253269
setup:
254270
ProcessTags.addTag("test", testValue)

0 commit comments

Comments
 (0)