Skip to content

Commit

Permalink
Add CPU count tag to Test Visibility events (#7659)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog authored and shatzi committed Sep 25, 2024
1 parent df3ed1f commit c75a2c2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class TestDecoratorImpl implements TestDecorator {
private final String component;
private final String sessionName;
private final Map<String, String> ciTags;
private final int cpuCount;

public TestDecoratorImpl(
String component, String sessionName, String testCommand, Map<String, String> ciTags) {
Expand All @@ -27,6 +28,7 @@ public TestDecoratorImpl(
this.sessionName =
Strings.isNotBlank(ciJobName) ? ciJobName + "-" + testCommand : testCommand;
}
cpuCount = Runtime.getRuntime().availableProcessors();
}

protected String testType() {
Expand All @@ -46,6 +48,7 @@ public CharSequence component() {
public AgentSpan afterStart(final AgentSpan span) {
span.setSamplingPriority(PrioritySampling.SAMPLER_KEEP);
span.setTag(DDTags.ORIGIN_KEY, CIAPP_TEST_ORIGIN);
span.setTag(DDTags.HOST_VCPU_COUNT, cpuCount);
span.setTag(Tags.TEST_TYPE, testType());
span.setTag(Tags.COMPONENT, component());
span.setTag(Tags.TEST_SESSION_NAME, sessionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TestDecoratorImplTest extends Specification {
1 * span.setTag(Tags.TEST_TYPE, decorator.testType())
1 * span.setSamplingPriority(PrioritySampling.SAMPLER_KEEP)
1 * span.setTag(DDTags.ORIGIN_KEY, decorator.origin())
1 * span.setTag(DDTags.HOST_VCPU_COUNT, Runtime.runtime.availableProcessors())
1 * span.setTag("ci-tag-1", "value")
1 * span.setTag("ci-tag-2", "another value")

Expand Down
1 change: 1 addition & 0 deletions dd-trace-api/src/main/java/datadog/trace/api/DDTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class DDTags {
public static final String PEER_SERVICE_REMAPPED_FROM = "_dd.peer.service.remapped_from";
public static final String INTERNAL_GIT_REPOSITORY_URL = "_dd.git.repository_url";
public static final String INTERNAL_GIT_COMMIT_SHA = "_dd.git.commit.sha";
public static final String HOST_VCPU_COUNT = "_dd.host.vcpu_count";

public static final String PROFILING_ENABLED = "_dd.profiling.enabled";
public static final String DSM_ENABLED = "_dd.dsm.enabled";
Expand Down

0 comments on commit c75a2c2

Please sign in to comment.