Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set test framework and test framework version tags atomically #8252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading