Skip to content

Commit

Permalink
Merge pull request #7661 from DataDog/mhlidd/DD_VERSION
Browse files Browse the repository at this point in the history
Remove `version` metadata for non `DD_SERVICE` spans
  • Loading branch information
mhlidd authored Oct 9, 2024
2 parents 14a45ea + cc28d89 commit 3ddea41
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public Map<String, Object> processTags(
&& spanContext != null
&& !ddService.toString().equalsIgnoreCase(spanContext.getServiceName())) {
unsafeTags.put(DDTags.BASE_SERVICE, ddService);
unsafeTags.remove("version");
}
return unsafeTags;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import datadog.trace.common.writer.ListWriter
import datadog.trace.common.writer.LoggingWriter
import datadog.trace.core.datastreams.DataStreamContextExtractor
import datadog.trace.core.propagation.HttpCodec
import datadog.trace.core.tagprocessor.TagsPostProcessorFactory
import datadog.trace.core.test.DDCoreSpecification
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
Expand Down Expand Up @@ -544,6 +545,32 @@ class CoreTracerTest extends DDCoreSpecification {
"some" | "some"
}

def "test dd_version exists only if service == dd_service"() {
setup:
injectSysConfig(SERVICE_NAME, "dd_service_name")
injectSysConfig(VERSION, "1.0.0")
TagsPostProcessorFactory.withAddBaseService(true)
def tracer = tracerBuilder().writer(new ListWriter()).build()

when:
def span = tracer.buildSpan("def").withTag(SERVICE_NAME,"foo").start()
span.finish()
then:
span.getServiceName() == "foo"
span.getTags().containsKey("version") == false

when:
def span2 = tracer.buildSpan("abc").start()
span2.finish()
then:
span2.getServiceName() == "dd_service_name"
span2.getTags()["version"] == "1.0.0"

cleanup:
tracer?.close()
}


def "reject configuration when target service+env mismatch"() {
setup:
injectSysConfig(SERVICE_NAME, service)
Expand Down

0 comments on commit 3ddea41

Please sign in to comment.