Skip to content

Commit 20a5542

Browse files
Set test framework and test framework version tags atomically
1 parent a69247f commit 20a5542

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/utils/SpanUtils.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import java.util.ArrayList;
88
import java.util.Collection;
99
import java.util.Collections;
10+
import java.util.HashMap;
1011
import java.util.Iterator;
12+
import java.util.Map;
1113
import java.util.TreeSet;
1214
import java.util.function.BinaryOperator;
1315
import java.util.function.Consumer;
@@ -83,8 +85,10 @@ private static void setFrameworks(AgentSpan span, Collection<TestFramework> fram
8385
}
8486
if (frameworks.size() == 1) {
8587
TestFramework framework = frameworks.iterator().next();
86-
span.setTag(Tags.TEST_FRAMEWORK, framework.getName());
87-
span.setTag(Tags.TEST_FRAMEWORK_VERSION, framework.getVersion());
88+
Map<String, String> tags = new HashMap<>();
89+
tags.put(Tags.TEST_FRAMEWORK, framework.getName());
90+
tags.put(Tags.TEST_FRAMEWORK_VERSION, framework.getVersion());
91+
span.setAllTags(tags);
8892
return;
8993
}
9094
Collection<String> names = new ArrayList<>(frameworks.size());
@@ -93,8 +97,10 @@ private static void setFrameworks(AgentSpan span, Collection<TestFramework> fram
9397
names.add(framework.getName());
9498
versions.add(framework.getVersion());
9599
}
96-
span.setTag(Tags.TEST_FRAMEWORK, names);
97-
span.setTag(Tags.TEST_FRAMEWORK_VERSION, versions);
100+
Map<String, Collection<String>> tags = new HashMap<>();
101+
tags.put(Tags.TEST_FRAMEWORK, names);
102+
tags.put(Tags.TEST_FRAMEWORK_VERSION, versions);
103+
span.setAllTags(tags);
98104
}
99105

100106
private static void propagateStatus(AgentSpan parentSpan, AgentSpan childSpan) {

dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ public DDSpan setTag(final String tag, final Object value) {
485485
return this;
486486
}
487487

488+
@Override
489+
public AgentSpan setAllTags(Map<String, ?> map) {
490+
context.setAllTags(map);
491+
return this;
492+
}
493+
488494
// FIXME [API] this is not on AgentSpan or MutableSpan
489495
@Override
490496
public DDSpan removeTag(final String tag) {

internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentSpan.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import datadog.trace.api.gateway.IGSpanInfo;
66
import datadog.trace.api.gateway.RequestContext;
77
import datadog.trace.api.interceptor.MutableSpan;
8+
import java.util.Map;
89

910
public interface AgentSpan extends MutableSpan, IGSpanInfo, WithAgentSpan {
1011

@@ -28,6 +29,8 @@ public interface AgentSpan extends MutableSpan, IGSpanInfo, WithAgentSpan {
2829

2930
AgentSpan setTag(String key, Object value);
3031

32+
AgentSpan setAllTags(Map<String, ?> map);
33+
3134
@Override
3235
AgentSpan setTag(String key, Number value);
3336

internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ public AgentSpan setTag(final String key, final Object value) {
610610
return this;
611611
}
612612

613+
@Override
614+
public AgentSpan setAllTags(Map<String, ?> map) {
615+
return this;
616+
}
617+
613618
@Override
614619
public AgentSpan setMetric(final CharSequence key, final int value) {
615620
return this;

0 commit comments

Comments
 (0)