Skip to content
Draft
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 @@ -29,7 +29,7 @@ public Collection<? extends MutableSpan> onTraceComplete(
String ciWorkspacePath = (String) firstSpan.getTag(Tags.CI_WORKSPACE_PATH);

GitInfo gitInfo = GitInfoProvider.INSTANCE.getGitInfo(ciWorkspacePath);
gitInfo.addTags(firstSpan);
gitInfo.addTo(firstSpan);

return trace;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import datadog.trace.api.DDTags;
import datadog.trace.api.TagMap;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.TagContributor;
import java.util.Objects;

public final class GitInfo {
public final class GitInfo implements TagContributor {
public static final GitInfo NOOP = new GitInfo(null, null, null, CommitInfo.NOOP);

private final String repositoryURL;
Expand All @@ -22,7 +23,7 @@ public GitInfo(String repositoryURL, String branch, String tag, CommitInfo commi
this.tag = tag;
this.commit = commit;

// GitInfo is reused across many traces, so create entries once and reuse them (see addTags)
// GitInfo is reused across many traces, so create entries once and reuse them (see addTo)
// null & empty values result in null entries which nop when added to a span
this.repositoryEntry = TagMap.Entry.create(DDTags.INTERNAL_GIT_REPOSITORY_URL, repositoryURL);
this.commitEntry =
Expand All @@ -47,7 +48,8 @@ public CommitInfo getCommit() {
return commit;
}

public void addTags(AgentSpan span) {
@Override
public void addTo(AgentSpan span) {
span.setTag(this.repositoryEntry);
span.setTag(this.commitEntry);
}
Expand Down
Loading