@@ -4,6 +4,7 @@ import static datadog.trace.api.config.GeneralConfig.EXPERIMENTAL_PROPAGATE_PROC
44
55import datadog.trace.api.env.CapturedEnvironment
66import datadog.trace.test.util.DDSpecification
7+ import datadog.trace.util.TraceUtils
78import java.nio.file.Paths
89
910class ProcessTagsForkedTest extends DDSpecification {
@@ -21,7 +22,6 @@ class ProcessTagsForkedTest extends DDSpecification {
2122
2223 def ' should load default tags for jar #jar and main class #cls' () {
2324 given :
24- injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED , " true" )
2525 CapturedEnvironment . useFixedProcessInfo(new CapturedEnvironment.ProcessInfo (cls, jar))
2626 ProcessTags . reset()
2727 def tags = ProcessTags . getTagsForSerialization()
@@ -35,9 +35,23 @@ class ProcessTagsForkedTest extends DDSpecification {
3535 null | null | " entrypoint.workdir:[^,]+"
3636 }
3737
38+ def ' should add process tags for service name set by user #userServiceName' () {
39+ given :
40+ if (userServiceName != null ) {
41+ injectSysConfig(" service" , userServiceName)
42+ }
43+ ProcessTags . reset()
44+ def tags = ProcessTags . getTagsForSerialization()
45+ expect :
46+ tags =~ expected
47+ where :
48+ userServiceName | expected
49+ null | " svc.auto:${ TraceUtils.normalizeServiceName(Config.get().getServiceName())} "
50+ " custom" | " svc.user:true"
51+ }
52+
3853 def 'should load default tags jboss (mode #mode )' () {
3954 setup:
40- injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "true")
4155 if (jbossHome != null) {
4256 System.setProperty("jboss.home.dir", jbossHome)
4357 }
@@ -62,7 +76,6 @@ class ProcessTagsForkedTest extends DDSpecification {
6276
6377 def 'should load websphere tags (#expected )' () {
6478 setup:
65- injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "true")
6679 ProcessTags.envGetter = key -> {
6780 switch (key) {
6881 case "WAS_CELL":
@@ -87,24 +100,24 @@ class ProcessTagsForkedTest extends DDSpecification {
87100 null | "server1" | "^((?!cluster.name|server.name|server.type).)*\$ "
88101 }
89102
90- def ' calculate process tags by default ' () {
103+ def ' can disable process tags' () {
91104 when:
105+ injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "false")
92106 ProcessTags.reset()
93107 def processTags = ProcessTags.tagsForSerialization
94108 then:
95- assert ProcessTags.enabled
96- assert (processTags ! = null)
109+ assert ! ProcessTags.enabled
110+ assert (processTags = = null)
97111 when:
98112 ProcessTags.addTag("test", "value")
99113 then:
100- assert (ProcessTags.tagsForSerialization ! = null)
101- assert (ProcessTags.tagsAsStringList ! = null)
102- assert (ProcessTags.tagsAsUTF8ByteStringList ! = null)
114+ assert (ProcessTags.tagsForSerialization = = null)
115+ assert (ProcessTags.tagsAsStringList = = null)
116+ assert (ProcessTags.tagsAsUTF8ByteStringList = = null)
103117 }
104118
105119 def ' should lazily recalculate when a tag is added' () {
106120 setup:
107- injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "true")
108121 ProcessTags.reset()
109122 when:
110123 def processTags = ProcessTags.tagsForSerialization
@@ -131,7 +144,6 @@ class ProcessTagsForkedTest extends DDSpecification {
131144
132145 def ' process tag value normalization' () {
133146 setup:
134- ProcessTags.reset()
135147 ProcessTags.addTag("test", testValue)
136148 expect:
137149 assert ProcessTags.tagsAsStringList != null
0 commit comments