Skip to content

Commit 3bbea85

Browse files
Set test framework and test framework version tags atomically (#8252)
1 parent 56d4919 commit 3bbea85

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
@@ -10,6 +10,7 @@
1010
import datadog.trace.api.gateway.IGSpanInfo;
1111
import datadog.trace.api.gateway.RequestContext;
1212
import datadog.trace.api.interceptor.MutableSpan;
13+
import java.util.Map;
1314
import javax.annotation.Nullable;
1415

1516
public interface AgentSpan
@@ -35,6 +36,8 @@ public interface AgentSpan
3536

3637
AgentSpan setTag(String key, Object value);
3738

39+
AgentSpan setAllTags(Map<String, ?> map);
40+
3841
@Override
3942
AgentSpan setTag(String key, Number value);
4043

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
@@ -642,6 +642,11 @@ public AgentSpan setTag(final String key, final Object value) {
642642
return this;
643643
}
644644

645+
@Override
646+
public AgentSpan setAllTags(Map<String, ?> map) {
647+
return this;
648+
}
649+
645650
@Override
646651
public AgentSpan setMetric(final CharSequence key, final int value) {
647652
return this;

0 commit comments

Comments
 (0)