From 70fa7419100d7774deb91047fa280adda3c2ed7f Mon Sep 17 00:00:00 2001 From: Nils Gruson Date: Tue, 5 Dec 2023 08:03:02 +0100 Subject: [PATCH] Updated CustomTextMapPropagator matching #5123 --- .../Shared/CustomTextMapPropagator.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/OpenTelemetry.Tests/Shared/CustomTextMapPropagator.cs b/test/OpenTelemetry.Tests/Shared/CustomTextMapPropagator.cs index 89e0a107a50..e22904fd126 100644 --- a/test/OpenTelemetry.Tests/Shared/CustomTextMapPropagator.cs +++ b/test/OpenTelemetry.Tests/Shared/CustomTextMapPropagator.cs @@ -21,23 +21,30 @@ namespace OpenTelemetry.Tests; internal sealed class CustomTextMapPropagator : TextMapPropagator { -#pragma warning disable SA1010 - public List ExtractValues = []; - public Dictionary> InjectValues = []; private static readonly PropagationContext DefaultPropagationContext = default; + public ActivityTraceId TraceId { get; set; } + + public ActivitySpanId SpanId { get; set; } + public Action Injected { get; set; } public override ISet Fields => null; +#pragma warning disable SA1201 // Elements should appear in the correct order +#pragma warning disable SA1010 // Opening square brackets should be spaced correctly + public Dictionary> InjectValues = []; +#pragma warning restore SA1010 // Opening square brackets should be spaced correctly +#pragma warning restore SA1201 // Elements should appear in the correct order + public override PropagationContext Extract(PropagationContext context, T carrier, Func> getter) { - if (this.ExtractValues.Count == 2) + if (this.TraceId != default && this.SpanId != default) { return new PropagationContext( new ActivityContext( - ActivityTraceId.CreateFromString(this.ExtractValues[0].ToCharArray()), - ActivitySpanId.CreateFromString(this.ExtractValues[1].ToCharArray()), + this.TraceId, + this.SpanId, ActivityTraceFlags.Recorded), default); }