Skip to content

Commit

Permalink
remove "_dd.agent_psr" only from TraceAnnotationsTests spanshots (#5591)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspimentel authored May 22, 2024
1 parent e81cd24 commit ba3b50b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
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

0 comments on commit ba3b50b

Please sign in to comment.