Skip to content

Commit 7d0d9a5

Browse files
put custom tags into a single defined attribute
1 parent cedc49c commit 7d0d9a5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

dd-java-agent/instrumentation/spark/src/main/java/datadog/trace/instrumentation/spark/AbstractDatadogSparkListener.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ private void initApplicationSpanIfNotInitialized() {
244244
AgentTracer.SpanBuilder builder = buildSparkSpan("spark.application", null);
245245

246246
if (applicationStart != null) {
247+
Config.get().getGlobalTags().entrySet().stream()
248+
.forEach(e -> builder.withTag("dd.tags." + e.getKey(), e.getValue()));
249+
247250
builder
248251
.withStartTimestamp(applicationStart.time() * 1000)
249252
.withTag("application_name", applicationStart.appName())

dd-java-agent/instrumentation/spark/src/testFixtures/groovy/datadog/trace/instrumentation/spark/AbstractSparkListenerTest.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,27 @@ abstract class AbstractSparkListenerTest extends InstrumentationSpecification {
588588
.contains("_dd.ol_intake.process_tags:" + ProcessTags.getTagsForSerialization())
589589
}
590590

591+
def "test all custom tags get propagated into a single attributes of application span"() {
592+
setup:
593+
def customTags = "tagKey1:tagKeyValue1,tagKey2:tagKeyValue2"
594+
injectSysConfig("dd.tags", customTags)
595+
def listener = getTestDatadogSparkListener()
596+
listener.onApplicationStart(applicationStartEvent(1000L))
597+
listener.onApplicationEnd(new SparkListenerApplicationEnd(5000L))
598+
599+
expect:
600+
assertTraces(1) {
601+
trace(1) {
602+
span {
603+
operationName "spark.application"
604+
spanType "spark"
605+
assert span.tags["dd.tags.tagKey1"] == "tagKeyValue1"
606+
assert span.tags["dd.tags.tagKey2"] == "tagKeyValue2"
607+
}
608+
}
609+
}
610+
}
611+
591612
def "test setupOpenLineage fills circuit breaker config"(
592613
Boolean configEnabled,
593614
String sparkConfCircuitBreakerType,

0 commit comments

Comments
 (0)