Skip to content

Commit 75bbf22

Browse files
authored
remove colons from process tags values (#10109)
1 parent ca74daf commit 75bbf22

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ static void calculate() {
146146
.map(
147147
entry ->
148148
UTF8BytesString.create(
149-
entry.getKey() + ":" + TraceUtils.normalizeTagValue(entry.getValue())));
149+
entry.getKey()
150+
+ ":"
151+
+ TraceUtils.normalizeTagValue(
152+
entry.getValue().replace(':', '_'))));
150153
utf8ListForm = Collections.unmodifiableList(tagStream.collect(Collectors.toList()));
151154
stringListForm =
152155
Collections.unmodifiableList(

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

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package datadog.trace.api
22

3+
import static datadog.trace.api.config.GeneralConfig.EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED
4+
35
import datadog.trace.api.env.CapturedEnvironment
46
import datadog.trace.test.util.DDSpecification
5-
67
import java.nio.file.Paths
78

8-
import static datadog.trace.api.config.GeneralConfig.EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED
9-
109
class ProcessTagsForkedTest extends DDSpecification {
1110

1211
def originalProcessInfo
@@ -129,4 +128,52 @@ class ProcessTagsForkedTest extends DDSpecification {
129128
assert ProcessTags.tagsAsStringList[0] == "0test:value"
130129
assert ProcessTags.tagsAsUTF8ByteStringList[0].toString() == "0test:value"
131130
}
131+
132+
def 'process tag value normalization'() {
133+
setup:
134+
ProcessTags.reset()
135+
ProcessTags.addTag("test", testValue)
136+
expect:
137+
assert ProcessTags.tagsAsStringList != null
138+
assert ProcessTags.tagsAsStringList.find { it.startsWith("test:") } == "test:${expectedValue}"
139+
140+
where:
141+
testValue | expectedValue
142+
"#test_starting_hash" | "test_starting_hash"
143+
"TestCAPSandSuch" | "testcapsandsuch"
144+
"Test Conversion Of Weird !@#\$%^&**() Characters" | "test_conversion_of_weird_characters"
145+
"\$#weird_starting" | "weird_starting"
146+
"disallowed:c0l0ns" | "disallowed_c0l0ns"
147+
"1love" | "1love"
148+
"123456" | "123456"
149+
"7.0" | "7.0"
150+
"ünicöde" | "ünicöde"
151+
"ünicöde:metäl" | "ünicöde_metäl"
152+
"Data🐨dog🐶 繋がっ⛰てて" | "data_dog_繋がっ_てて"
153+
" spaces " | "spaces"
154+
" #hashtag!@#spaces #__<># " | "hashtag_spaces"
155+
":testing" | "testing"
156+
"_foo" | "foo"
157+
":::test" | "test"
158+
"contiguous_____underscores" | "contiguous_underscores"
159+
"foo_" | "foo"
160+
"" | ""
161+
" " | ""
162+
"ok" | "ok"
163+
"AlsO:ök" | "also_ök"
164+
":still_ok" | "still_ok"
165+
"___trim" | "trim"
166+
"fun:ky__tag/1" | "fun_ky_tag/1"
167+
"fun:ky@tag/2" | "fun_ky_tag/2"
168+
"fun:ky@@@tag/3" | "fun_ky_tag/3"
169+
"tag:1/2.3" | "tag_1/2.3"
170+
"---fun:k####y_ta@#g/1_@@#" | "fun_k_y_ta_g/1"
171+
"AlsO:œ#@ö))œk" | "also_œ_ö_œk"
172+
" regulartag " | "regulartag"
173+
"\u017Fodd_\u017Fcase\u017F" | "\u017Fodd_\u017Fcase\u017F"
174+
"™Ö™Ö™™Ö™" | "ö_ö_ö"
175+
"a�" | "a"
176+
"a��" | "a"
177+
"a��b" | "a_b"
178+
}
132179
}

0 commit comments

Comments
 (0)