Skip to content

Commit

Permalink
Set test framework and test framework version tags atomically
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog committed Jan 22, 2025
1 parent ad44687 commit a83cee4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeSet;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
Expand Down Expand Up @@ -83,8 +85,10 @@ private static void setFrameworks(AgentSpan span, Collection<TestFramework> fram
}
if (frameworks.size() == 1) {
TestFramework framework = frameworks.iterator().next();
span.setTag(Tags.TEST_FRAMEWORK, framework.getName());
span.setTag(Tags.TEST_FRAMEWORK_VERSION, framework.getVersion());
Map<String, String> tags = new HashMap<>();
tags.put(Tags.TEST_FRAMEWORK, framework.getName());
tags.put(Tags.TEST_FRAMEWORK_VERSION, framework.getVersion());
span.setAllTags(tags);
return;
}
Collection<String> names = new ArrayList<>(frameworks.size());
Expand All @@ -93,8 +97,10 @@ private static void setFrameworks(AgentSpan span, Collection<TestFramework> fram
names.add(framework.getName());
versions.add(framework.getVersion());
}
span.setTag(Tags.TEST_FRAMEWORK, names);
span.setTag(Tags.TEST_FRAMEWORK_VERSION, versions);
Map<String, Collection<String>> tags = new HashMap<>();
tags.put(Tags.TEST_FRAMEWORK, names);
tags.put(Tags.TEST_FRAMEWORK_VERSION, versions);
span.setAllTags(tags);
}

private static void propagateStatus(AgentSpan parentSpan, AgentSpan childSpan) {
Expand Down
6 changes: 6 additions & 0 deletions dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ public DDSpan setTag(final String tag, final Object value) {
return this;
}

@Override
public AgentSpan setAllTags(Map<String, ?> map) {
context.setAllTags(map);
return this;
}

// FIXME [API] this is not on AgentSpan or MutableSpan
@Override
public DDSpan removeTag(final String tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import datadog.trace.api.gateway.IGSpanInfo;
import datadog.trace.api.gateway.RequestContext;
import datadog.trace.api.interceptor.MutableSpan;
import java.util.Map;
import javax.annotation.Nullable;

public interface AgentSpan
Expand All @@ -35,6 +36,8 @@ public interface AgentSpan

AgentSpan setTag(String key, Object value);

AgentSpan setAllTags(Map<String, ?> map);

@Override
AgentSpan setTag(String key, Number value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,11 @@ public AgentSpan setTag(final String key, final Object value) {
return this;
}

@Override
public AgentSpan setAllTags(Map<String, ?> map) {
return this;
}

@Override
public AgentSpan setMetric(final CharSequence key, final int value) {
return this;
Expand Down

0 comments on commit a83cee4

Please sign in to comment.