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

[Tracer][Tests] scrub _dd.agent_psr tag from TraceAnnotationsTests snapshots only #5591

Merged
merged 1 commit into from
May 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma warning disable SA1402 // File may only contain a single class
#pragma warning disable SA1649 // File name must match first type name

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Datadog.Trace.Configuration;
Expand Down Expand Up @@ -155,13 +156,30 @@ public async Task SubmitTraces()
telemetry?.AssertConfiguration("DD_TRACE_METHODS"); // normalised to trace_methods in the backend

// Run snapshot verification
var settings = VerifyHelper.GetSpanVerifierSettings();
var settings = VerifyHelper.GetSpanVerifierSettings(
scrubbers: null,
parameters: [],
apmStringTagsScrubber: VerifyHelper.ScrubStringTags, // remove "_dd.agent_psr" to prevent flake
apmNumericTagsScrubber: ApmNumericTagsScrubber,
ciVisStringTagsScrubber: null,
ciVisNumericTagsScrubber: null);

await Verifier.Verify(orderedSpans, settings)
.UniqueForRuntime()
.UseMethodName("_");
}

telemetry?.Dispose();
return;

// remove "_dd.agent_psr"
static Dictionary<string, double> ApmNumericTagsScrubber(MockSpan target, Dictionary<string, double> tags)
{
return tags
?.Where(kvp => !string.Equals(kvp.Key, Metrics.SamplingAgentDecision))
.OrderBy(x => x.Key)
.ToDictionary(x => x.Key, x => x.Value);
}
}

[SkippableFact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,7 @@ public static void AddSimpleScrubber(this VerifySettings settings, string oldVal

public static Dictionary<string, double>? ScrubNumericTags(MockSpan span, Dictionary<string, double>? tags)
{
string[] ignoreKeys =
[
Metrics.SamplingAgentDecision,
// more coming soon
];
return tags
?.Where(kvp => !ignoreKeys.Contains(kvp.Key))
.OrderBy(x => x.Key)
.ToDictionary(x => x.Key, x => x.Value);
return tags; // no-op
}

public static Dictionary<string, string>? ScrubCIVisibilityTags(MockSpan span, Dictionary<string, string>? tags) => ScrubCIVisibilityTags(tags);
Expand Down
Loading