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

[CI Visibility] Specify if the user is setting the DD_SERVICE #6348

Merged
merged 5 commits into from
Nov 26, 2024
Merged
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
11 changes: 11 additions & 0 deletions tracer/src/Datadog.Trace/Ci/CIVisibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Datadog.Trace.Agent.Transports;
using Datadog.Trace.Ci.CiEnvironment;
using Datadog.Trace.Ci.Configuration;
using Datadog.Trace.Ci.Tags;
using Datadog.Trace.Configuration;
using Datadog.Trace.HttpOverStreams;
using Datadog.Trace.Logging;
Expand Down Expand Up @@ -134,6 +135,11 @@ public static void Initialize()
{
// Extract repository name from the git url and use it as a default service name.
tracerSettings.ServiceNameInternal = GetServiceNameFromRepository(CIEnvironmentValues.Instance.Repository);
tracerSettings.GlobalTagsInternal[CommonTags.UserProvidedTestServiceTag] = "false";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought, given this is added to every span, maybe you want to add it as part of the serialization directly instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I'll do that in a different optimization PR though

}
else
{
tracerSettings.GlobalTagsInternal[CommonTags.UserProvidedTestServiceTag] = "true";
}

// Normalize the service name
Expand Down Expand Up @@ -203,6 +209,11 @@ internal static void InitializeFromRunner(CIVisibilitySettings settings, IDiscov
{
// Extract repository name from the git url and use it as a default service name.
tracerSettings.ServiceNameInternal = GetServiceNameFromRepository(CIEnvironmentValues.Instance.Repository);
tracerSettings.GlobalTagsInternal[CommonTags.UserProvidedTestServiceTag] = "false";
}
else
{
tracerSettings.GlobalTagsInternal[CommonTags.UserProvidedTestServiceTag] = "true";
}

// Normalize the service name
Expand Down
5 changes: 5 additions & 0 deletions tracer/src/Datadog.Trace/Ci/Tags/CommonTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,9 @@ internal static class CommonTags
/// GIT PR Base branch name
/// </summary>
public const string GitPrBaseBranch = "git.pull_request.base_branch";

/// <summary>
/// Defines if the service is a user provided test service
/// </summary>
public const string UserProvidedTestServiceTag = "_dd.test.is_user_provided_service";
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ await Verifier.Verify(
targetTest.Meta.Remove(EarlyFlakeDetectionTags.TestIsNew);
targetTest.Meta.Remove(EarlyFlakeDetectionTags.TestIsRetry);

// Remove user provided service tag
targetTest.Meta.Remove(CommonTags.UserProvidedTestServiceTag);

// check the name
Assert.Equal("mstestv2.test", targetTest.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public async Task SubmitTraces(string packageVersion)
targetSpan.Tags.Remove(EarlyFlakeDetectionTags.TestIsNew);
targetSpan.Tags.Remove(EarlyFlakeDetectionTags.TestIsRetry);

// Remove user provided service tag
targetSpan.Tags.Remove(CommonTags.UserProvidedTestServiceTag);

// check the name
Assert.Equal("mstestv2.test", targetSpan.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ public async Task SubmitTraces(string packageVersion, string evpVersionToRemove,
targetTest.Meta.Remove(EarlyFlakeDetectionTags.TestIsNew);
targetTest.Meta.Remove(EarlyFlakeDetectionTags.TestIsRetry);

// Remove user provided service tag
targetTest.Meta.Remove(CommonTags.UserProvidedTestServiceTag);

// check the name
Assert.Equal("nunit.test", targetTest.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public async Task SubmitTraces(string packageVersion)
targetSpan.Tags.Remove(EarlyFlakeDetectionTags.TestIsNew);
targetSpan.Tags.Remove(EarlyFlakeDetectionTags.TestIsRetry);

// Remove user provided service tag
targetSpan.Tags.Remove(CommonTags.UserProvidedTestServiceTag);

// check the name
targetSpan.Name.Should().Be("nunit.test");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ public virtual async Task SubmitTraces(string packageVersion, string evpVersionT
targetTest.Meta.Remove(EarlyFlakeDetectionTags.TestIsNew);
targetTest.Meta.Remove(EarlyFlakeDetectionTags.TestIsRetry);

// Remove user provided service tag
targetTest.Meta.Remove(CommonTags.UserProvidedTestServiceTag);

// check the name
Assert.Equal("xunit.test", targetTest.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public virtual async Task SubmitTraces(string packageVersion)
targetSpan.Tags.Remove(EarlyFlakeDetectionTags.TestIsNew);
targetSpan.Tags.Remove(EarlyFlakeDetectionTags.TestIsRetry);

// Remove user provided service tag
targetSpan.Tags.Remove(CommonTags.UserProvidedTestServiceTag);

// check the name
Assert.Equal("xunit.test", targetSpan.Name);

Expand Down
Loading
Loading