From 2de44438056d0efc2e846a086b6def3b2dbb7b42 Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Fri, 28 Aug 2020 05:00:28 -0300 Subject: [PATCH 1/2] Renaming ITextFormat to IPropagator --- .../Utils/Messaging/MessageReceiver.cs | 4 ++-- .../Utils/Messaging/MessageSender.cs | 4 ++-- .../Context/Propagation/B3Propagator.cs | 2 +- .../Context/Propagation/BaggagePropagator.cs | 2 +- .../Context/Propagation/CompositePropagator.cs | 18 +++++++++--------- .../{ITextFormat.cs => IPropagator.cs} | 4 ++-- .../Context/Propagation/TextMapPropagator.cs | 2 +- .../AspNetInstrumentationOptions.cs | 4 ++-- .../Implementation/HttpInListener.cs | 8 ++++---- .../AspNetCoreInstrumentationOptions.cs | 4 ++-- .../Implementation/HttpInListener.cs | 4 ++-- .../HttpClientInstrumentationOptions.cs | 4 ++-- ...tpWebRequestInstrumentationOptions.netfx.cs | 4 ++-- .../HttpHandlerDiagnosticListener.cs | 6 +++--- .../HttpWebRequestActivitySource.netfx.cs | 4 ++-- .../TracerShim.cs | 11 +++++------ .../HttpInListenerTests.cs | 6 +++--- .../BasicTests.cs | 8 ++++---- .../HttpClientTests.Basic.netcore31.cs | 10 +++++----- .../HttpWebRequestTests.Basic.netfx.cs | 6 +++--- .../Propagation/CompositePropagatorTest.cs | 6 +++--- .../Trace/Propagation/TestPropagator.cs | 2 +- 22 files changed, 61 insertions(+), 62 deletions(-) rename src/OpenTelemetry.Api/Context/Propagation/{ITextFormat.cs => IPropagator.cs} (96%) diff --git a/examples/MicroserviceExample/Utils/Messaging/MessageReceiver.cs b/examples/MicroserviceExample/Utils/Messaging/MessageReceiver.cs index 82a3945df93..e90dea13065 100644 --- a/examples/MicroserviceExample/Utils/Messaging/MessageReceiver.cs +++ b/examples/MicroserviceExample/Utils/Messaging/MessageReceiver.cs @@ -30,7 +30,7 @@ namespace Utils.Messaging public class MessageReceiver : IDisposable { private static readonly ActivitySource ActivitySource = new ActivitySource(nameof(MessageReceiver)); - private static readonly ITextFormat TextFormat = new TextMapPropagator(); + private static readonly IPropagator Propagator = new TextMapPropagator(); private readonly ILogger logger; private readonly IConnection connection; @@ -57,7 +57,7 @@ public void StartConsumer() public void ReceiveMessage(BasicDeliverEventArgs ea) { // Extract the ActivityContext of the upstream parent from the message headers. - var parentContext = TextFormat.Extract(default, ea.BasicProperties, this.ExtractTraceContextFromBasicProperties); + var parentContext = Propagator.Extract(default, ea.BasicProperties, this.ExtractTraceContextFromBasicProperties); // Start an activity with a name following the semantic convention of the OpenTelemetry messaging specification. // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/messaging.md#span-name diff --git a/examples/MicroserviceExample/Utils/Messaging/MessageSender.cs b/examples/MicroserviceExample/Utils/Messaging/MessageSender.cs index 95f81c22716..495beae5fb5 100644 --- a/examples/MicroserviceExample/Utils/Messaging/MessageSender.cs +++ b/examples/MicroserviceExample/Utils/Messaging/MessageSender.cs @@ -28,7 +28,7 @@ namespace Utils.Messaging public class MessageSender : IDisposable { private static readonly ActivitySource ActivitySource = new ActivitySource(nameof(MessageSender)); - private static readonly ITextFormat TextFormat = new TextMapPropagator(); + private static readonly IPropagator Propagator = new TextMapPropagator(); private readonly ILogger logger; private readonly IConnection connection; @@ -62,7 +62,7 @@ public string SendMessage() if (activity != null) { // Inject the ActivityContext into the message headers to propagate trace context to the receiving service. - TextFormat.Inject(new PropagationContext(activity.Context, Baggage.Current), props, this.InjectTraceContextIntoBasicProperties); + Propagator.Inject(new PropagationContext(activity.Context, Baggage.Current), props, this.InjectTraceContextIntoBasicProperties); // The OpenTelemetry messaging specification defines a number of attributes. These attributes are added here. RabbitMqHelper.AddMessagingTags(activity); diff --git a/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs b/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs index d08752abbee..53e46577e8e 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs @@ -26,7 +26,7 @@ namespace OpenTelemetry.Context.Propagation /// /// B3 text propagator. See https://github.com/openzipkin/b3-propagation for the specification. /// - public sealed class B3Propagator : ITextFormat + public sealed class B3Propagator : IPropagator { internal const string XB3TraceId = "X-B3-TraceId"; internal const string XB3SpanId = "X-B3-SpanId"; diff --git a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs index c04bed82734..912dc770667 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs @@ -26,7 +26,7 @@ namespace OpenTelemetry.Context.Propagation /// /// W3C baggage: https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md. /// - public class BaggagePropagator : ITextFormat + public class BaggagePropagator : IPropagator { internal const string BaggageHeaderName = "Baggage"; diff --git a/src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs index dda775342a6..c2c7660fa69 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/CompositePropagator.cs @@ -22,18 +22,18 @@ namespace OpenTelemetry.Context.Propagation /// /// CompositePropagator provides a mechanism for combining multiple propagators into a single one. /// - public class CompositePropagator : ITextFormat + public class CompositePropagator : IPropagator { private static readonly ISet EmptyFields = new HashSet(); - private readonly List textFormats; + private readonly List propagators; /// /// Initializes a new instance of the class. /// - /// List of wire context propagator. - public CompositePropagator(IEnumerable textFormats) + /// List of wire context propagator. + public CompositePropagator(IEnumerable propagators) { - this.textFormats = new List(textFormats ?? throw new ArgumentNullException(nameof(textFormats))); + this.propagators = new List(propagators ?? throw new ArgumentNullException(nameof(propagators))); } /// @@ -42,9 +42,9 @@ public CompositePropagator(IEnumerable textFormats) /// public PropagationContext Extract(PropagationContext context, T carrier, Func> getter) { - foreach (var textFormat in this.textFormats) + foreach (var propagator in this.propagators) { - context = textFormat.Extract(context, carrier, getter); + context = propagator.Extract(context, carrier, getter); } return context; @@ -53,9 +53,9 @@ public PropagationContext Extract(PropagationContext context, T carrier, Func /// public void Inject(PropagationContext context, T carrier, Action setter) { - foreach (var textFormat in this.textFormats) + foreach (var propagator in this.propagators) { - textFormat.Inject(context, carrier, setter); + propagator.Inject(context, carrier, setter); } } } diff --git a/src/OpenTelemetry.Api/Context/Propagation/ITextFormat.cs b/src/OpenTelemetry.Api/Context/Propagation/IPropagator.cs similarity index 96% rename from src/OpenTelemetry.Api/Context/Propagation/ITextFormat.cs rename to src/OpenTelemetry.Api/Context/Propagation/IPropagator.cs index f79e5639b3d..4f329b098c4 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/ITextFormat.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/IPropagator.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ namespace OpenTelemetry.Context.Propagation /// Text format wire context propagator. Helps to extract and inject context from textual /// representation (typically http headers or metadata collection). /// - public interface ITextFormat + public interface IPropagator { /// /// Gets the list of headers used by propagator. The use cases of this are: diff --git a/src/OpenTelemetry.Api/Context/Propagation/TextMapPropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/TextMapPropagator.cs index a499a6385a5..6cc4341a0da 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/TextMapPropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/TextMapPropagator.cs @@ -26,7 +26,7 @@ namespace OpenTelemetry.Context.Propagation /// /// W3C trace context text wire protocol formatter. See https://github.com/w3c/distributed-tracing/. /// - public class TextMapPropagator : ITextFormat + public class TextMapPropagator : IPropagator { private const string TraceParent = "traceparent"; private const string TraceState = "tracestate"; diff --git a/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs index 20f2626face..4a8e9a0735c 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs @@ -26,9 +26,9 @@ namespace OpenTelemetry.Instrumentation.AspNet public class AspNetInstrumentationOptions { /// - /// Gets or sets for context propagation. Default value: with & . + /// Gets or sets for context propagation. Default value: with & . /// - public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[] + public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[] { new TextMapPropagator(), new BaggagePropagator(), diff --git a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs index 9f0cc2faf85..83a18c53f11 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs @@ -72,9 +72,9 @@ public override void OnStartActivity(Activity activity, object payload) var request = context.Request; var requestValues = request.Unvalidated; - if (!(this.options.TextFormat is TextMapPropagator)) + if (!(this.options.Propagator is TextMapPropagator)) { - var ctx = this.options.TextFormat.Extract(default, request, HttpRequestHeaderValuesGetter); + var ctx = this.options.Propagator.Extract(default, request, HttpRequestHeaderValuesGetter); if (ctx.ActivityContext.IsValid() && ctx.ActivityContext != activity.Context) { @@ -132,7 +132,7 @@ public override void OnStopActivity(Activity activity, object payload) Activity activityToEnrich = activity; Activity createdActivity = null; - if (!(this.options.TextFormat is TextMapPropagator)) + if (!(this.options.Propagator is TextMapPropagator)) { // If using custom context propagator, then the activity here // could be either the one from Asp.Net, or the one @@ -197,7 +197,7 @@ public override void OnStopActivity(Activity activity, object payload) } } - if (!(this.options.TextFormat is TextMapPropagator)) + if (!(this.options.Propagator is TextMapPropagator)) { if (activity.OperationName.Equals(ActivityNameByHttpInListener)) { diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationOptions.cs index 85b6e989e79..4b496e25d45 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationOptions.cs @@ -26,9 +26,9 @@ namespace OpenTelemetry.Instrumentation.AspNetCore public class AspNetCoreInstrumentationOptions { /// - /// Gets or sets for context propagation. Default value: with & . + /// Gets or sets for context propagation. Default value: with & . /// - public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[] + public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[] { new TextMapPropagator(), new BaggagePropagator(), diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 4481637e563..f394b70c083 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -78,9 +78,9 @@ public override void OnStartActivity(Activity activity, object payload) } var request = context.Request; - if (!this.hostingSupportsW3C || !(this.options.TextFormat is TextMapPropagator)) + if (!this.hostingSupportsW3C || !(this.options.Propagator is TextMapPropagator)) { - var ctx = this.options.TextFormat.Extract(default, request, HttpRequestHeaderValuesGetter); + var ctx = this.options.Propagator.Extract(default, request, HttpRequestHeaderValuesGetter); if (ctx.ActivityContext.IsValid() && ctx.ActivityContext != activity.Context) { diff --git a/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentationOptions.cs index 240ad63550b..6dc0d58109d 100644 --- a/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentationOptions.cs @@ -34,9 +34,9 @@ public class HttpClientInstrumentationOptions public bool SetHttpFlavor { get; set; } /// - /// Gets or sets for context propagation. Default value: with & . + /// Gets or sets for context propagation. Default value: with & . /// - public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[] + public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[] { new TextMapPropagator(), new BaggagePropagator(), diff --git a/src/OpenTelemetry.Instrumentation.Http/HttpWebRequestInstrumentationOptions.netfx.cs b/src/OpenTelemetry.Instrumentation.Http/HttpWebRequestInstrumentationOptions.netfx.cs index 3bc97710722..67dff2bb2af 100644 --- a/src/OpenTelemetry.Instrumentation.Http/HttpWebRequestInstrumentationOptions.netfx.cs +++ b/src/OpenTelemetry.Instrumentation.Http/HttpWebRequestInstrumentationOptions.netfx.cs @@ -34,9 +34,9 @@ public class HttpWebRequestInstrumentationOptions public bool SetHttpFlavor { get; set; } /// - /// Gets or sets for context propagation. Default value: with & . + /// Gets or sets for context propagation. Default value: with & . /// - public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[] + public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[] { new TextMapPropagator(), new BaggagePropagator(), diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 79062e15216..36c05eaafe0 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -86,7 +86,7 @@ public override void OnStartActivity(Activity activity, object payload) return; } - if (this.options.TextFormat.Extract(default, request, HttpRequestMessageHeaderValuesGetter) != default) + if (this.options.Propagator.Extract(default, request, HttpRequestMessageHeaderValuesGetter) != default) { // this request is already instrumented, we should back off activity.IsAllDataRequested = false; @@ -110,9 +110,9 @@ public override void OnStartActivity(Activity activity, object payload) } } - if (!(this.httpClientSupportsW3C && this.options.TextFormat is TextMapPropagator)) + if (!(this.httpClientSupportsW3C && this.options.Propagator is TextMapPropagator)) { - this.options.TextFormat.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpRequestMessageHeaderValueSetter); + this.options.Propagator.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpRequestMessageHeaderValueSetter); } } diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs index 4d31674cb38..782053e75de 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpWebRequestActivitySource.netfx.cs @@ -190,11 +190,11 @@ private static void AddExceptionTags(Exception exception, Activity activity) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void InstrumentRequest(HttpWebRequest request, Activity activity) - => Options.TextFormat.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpWebRequestHeaderValuesSetter); + => Options.Propagator.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpWebRequestHeaderValuesSetter); [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool IsRequestInstrumented(HttpWebRequest request) - => Options.TextFormat.Extract(default, request, HttpWebRequestHeaderValuesGetter) != default; + => Options.Propagator.Extract(default, request, HttpWebRequestHeaderValuesGetter) != default; private static void ProcessRequest(HttpWebRequest request) { diff --git a/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs b/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs index aa07208f898..210da1386b2 100644 --- a/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs +++ b/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using global::OpenTracing.Propagation; -using OpenTelemetry.Context; using OpenTelemetry.Context.Propagation; namespace OpenTelemetry.Shims.OpenTracing @@ -25,12 +24,12 @@ namespace OpenTelemetry.Shims.OpenTracing public class TracerShim : global::OpenTracing.ITracer { private readonly Trace.Tracer tracer; - private readonly ITextFormat textFormat; + private readonly IPropagator propagator; - public TracerShim(Trace.Tracer tracer, ITextFormat textFormat) + public TracerShim(Trace.Tracer tracer, IPropagator textFormat) { this.tracer = tracer ?? throw new ArgumentNullException(nameof(tracer)); - this.textFormat = textFormat ?? throw new ArgumentNullException(nameof(textFormat)); + this.propagator = textFormat ?? throw new ArgumentNullException(nameof(textFormat)); this.ScopeManager = new ScopeManagerShim(this.tracer); } @@ -81,7 +80,7 @@ static IEnumerable GetCarrierKeyValue(Dictionary( if ((format == BuiltinFormats.TextMap || format == BuiltinFormats.HttpHeaders) && carrier is ITextMap textMapCarrier) { - this.textFormat.Inject( + this.propagator.Inject( new PropagationContext(shim.SpanContext, Baggage.Current), textMapCarrier, (instrumentation, key, value) => instrumentation.Set(key, value)); diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs index f7582a8c47a..099178ca4ac 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs @@ -128,8 +128,8 @@ public void AspNetRequestsAreCollectedSuccessfully( var expectedTraceId = ActivityTraceId.CreateRandom(); var expectedSpanId = ActivitySpanId.CreateRandom(); - var textFormat = new Mock(); - textFormat.Setup(m => m.Extract(It.IsAny(), It.IsAny(), It.IsAny>>())).Returns(new PropagationContext( + var propagator = new Mock(); + propagator.Setup(m => m.Extract(It.IsAny(), It.IsAny(), It.IsAny>>())).Returns(new PropagationContext( new ActivityContext( expectedTraceId, expectedSpanId, @@ -160,7 +160,7 @@ public void AspNetRequestsAreCollectedSuccessfully( if (!carrierFormat.Equals("TraceContext")) { - options.TextFormat = textFormat.Object; + options.Propagator = propagator.Object; } }) .SetResource(expectedResource) diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs index 027338a5eb8..605df5e413f 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs @@ -136,15 +136,15 @@ public async Task SuccessfulTemplateControllerCallUsesParentContext() } [Fact] - public async Task CustomTextFormat() + public async Task CustomPropagator() { var activityProcessor = new Mock(); var expectedTraceId = ActivityTraceId.CreateRandom(); var expectedSpanId = ActivitySpanId.CreateRandom(); - var textFormat = new Mock(); - textFormat.Setup(m => m.Extract(It.IsAny(), It.IsAny(), It.IsAny>>())).Returns( + var propagator = new Mock(); + propagator.Setup(m => m.Extract(It.IsAny(), It.IsAny(), It.IsAny>>())).Returns( new PropagationContext( new ActivityContext( expectedTraceId, @@ -158,7 +158,7 @@ public async Task CustomTextFormat() builder.ConfigureTestServices(services => { this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder() - .AddAspNetCoreInstrumentation((opt) => opt.TextFormat = textFormat.Object) + .AddAspNetCoreInstrumentation((opt) => opt.Propagator = propagator.Object) .AddProcessor(activityProcessor.Object) .Build(); }))) diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.netcore31.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.netcore31.cs index 54fac79ee53..355c4968e5f 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.netcore31.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.netcore31.cs @@ -73,7 +73,7 @@ public async Task HttpClientInstrumentationInjectsHeadersAsync() parent.ActivityTraceFlags = ActivityTraceFlags.Recorded; // Ensure that the header value func does not throw if the header key can't be found - var mockTextFormat = new Mock(); + var mockPropagator = new Mock(); // var isInjectedHeaderValueGetterThrows = false; // mockTextFormat @@ -93,7 +93,7 @@ public async Task HttpClientInstrumentationInjectsHeadersAsync() // }); using (Sdk.CreateTracerProviderBuilder() - .AddHttpClientInstrumentation(o => o.TextFormat = mockTextFormat.Object) + .AddHttpClientInstrumentation(o => o.Propagator = mockPropagator.Object) .AddProcessor(processor.Object) .Build()) { @@ -122,8 +122,8 @@ public async Task HttpClientInstrumentationInjectsHeadersAsync() [Fact] public async Task HttpClientInstrumentationInjectsHeadersAsync_CustomFormat() { - var textFormat = new Mock(); - textFormat.Setup(m => m.Inject(It.IsAny(), It.IsAny(), It.IsAny>())) + var propagator = new Mock(); + propagator.Setup(m => m.Inject(It.IsAny(), It.IsAny(), It.IsAny>())) .Callback>((context, message, action) => { action(message, "custom_traceparent", $"00/{context.ActivityContext.TraceId}/{context.ActivityContext.SpanId}/01"); @@ -145,7 +145,7 @@ public async Task HttpClientInstrumentationInjectsHeadersAsync_CustomFormat() parent.ActivityTraceFlags = ActivityTraceFlags.Recorded; using (Sdk.CreateTracerProviderBuilder() - .AddHttpClientInstrumentation((opt) => opt.TextFormat = textFormat.Object) + .AddHttpClientInstrumentation((opt) => opt.Propagator = propagator.Object) .AddProcessor(processor.Object) .Build()) { diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.netfx.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.netfx.cs index 31be40502c8..d21265498b1 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.netfx.cs @@ -98,8 +98,8 @@ public async Task HttpWebRequestInstrumentationInjectsHeadersAsync() [Fact] public async Task HttpWebRequestInstrumentationInjectsHeadersAsync_CustomFormat() { - var textFormat = new Mock(); - textFormat.Setup(m => m.Inject(It.IsAny(), It.IsAny(), It.IsAny>())) + var propagator = new Mock(); + propagator.Setup(m => m.Inject(It.IsAny(), It.IsAny(), It.IsAny>())) .Callback>((context, message, action) => { action(message, "custom_traceparent", $"00/{context.ActivityContext.TraceId}/{context.ActivityContext.SpanId}/01"); @@ -109,7 +109,7 @@ public async Task HttpWebRequestInstrumentationInjectsHeadersAsync_CustomFormat( var activityProcessor = new Mock(); using var shutdownSignal = Sdk.CreateTracerProviderBuilder() .AddProcessor(activityProcessor.Object) - .AddHttpWebRequestInstrumentation(options => options.TextFormat = textFormat.Object) + .AddHttpWebRequestInstrumentation(options => options.Propagator = propagator.Object) .Build(); var request = (HttpWebRequest)WebRequest.Create(this.url); diff --git a/test/OpenTelemetry.Tests/Trace/Propagation/CompositePropagatorTest.cs b/test/OpenTelemetry.Tests/Trace/Propagation/CompositePropagatorTest.cs index d31ee34a2be..ed8c884a182 100644 --- a/test/OpenTelemetry.Tests/Trace/Propagation/CompositePropagatorTest.cs +++ b/test/OpenTelemetry.Tests/Trace/Propagation/CompositePropagatorTest.cs @@ -55,7 +55,7 @@ public void CompositePropagator_NullTextFormatList() [Fact] public void CompositePropagator_TestPropagator() { - var compositePropagator = new CompositePropagator(new List + var compositePropagator = new CompositePropagator(new List { new TestPropagator("custom-traceparent-1", "custom-tracestate-1"), new TestPropagator("custom-traceparent-2", "custom-tracestate-2"), @@ -77,7 +77,7 @@ public void CompositePropagator_UsingSameTag() const string header01 = "custom-tracestate-01"; const string header02 = "custom-tracestate-02"; - var compositePropagator = new CompositePropagator(new List + var compositePropagator = new CompositePropagator(new List { new TestPropagator("custom-traceparent", header01, true), new TestPropagator("custom-traceparent", header02), @@ -106,7 +106,7 @@ public void CompositePropagator_UsingSameTag() [Fact] public void CompositePropagator_ActivityContext_Baggage() { - var compositePropagator = new CompositePropagator(new List + var compositePropagator = new CompositePropagator(new List { new TextMapPropagator(), new BaggagePropagator(), diff --git a/test/OpenTelemetry.Tests/Trace/Propagation/TestPropagator.cs b/test/OpenTelemetry.Tests/Trace/Propagation/TestPropagator.cs index c13d1f7a039..2b84c671f6d 100644 --- a/test/OpenTelemetry.Tests/Trace/Propagation/TestPropagator.cs +++ b/test/OpenTelemetry.Tests/Trace/Propagation/TestPropagator.cs @@ -21,7 +21,7 @@ namespace OpenTelemetry.Context.Propagation.Tests { - public class TestPropagator : ITextFormat + public class TestPropagator : IPropagator { private readonly string idHeaderName; private readonly string stateHeaderName; From 4460e68393cc7b0410abc80ddd0028101671668f Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Fri, 28 Aug 2020 05:02:50 -0300 Subject: [PATCH 2/2] updating changelog --- src/OpenTelemetry.Api/CHANGELOG.md | 2 ++ src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md | 2 ++ src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 2 ++ src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md | 2 ++ src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md | 3 +++ 5 files changed, 11 insertions(+) diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index e0798e8360b..15cf64e8b89 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -52,6 +52,8 @@ * Renamed `TraceContextFormat` to `TextMapPropagator`, `BaggageFormat` to `BaggagePropagator`, and `B3Format` to `B3Propagator` ([#1175](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1175)) +* Renamed `ITextPropagator` to `IPropagator` + ([#1190](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1190)) ## 0.4.0-beta.2 diff --git a/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md index 16b3835a20f..3ea97a3815d 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md @@ -14,6 +14,8 @@ BaggageFormat)`. Baggage sent via the [W3C Baggage](https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md) header will now be parsed and set on incoming Http spans. +* Renamed `ITextPropagator` to `IPropagator` + ([#1190](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1190)) ## 0.4.0-beta.2 diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 496775eb656..0447b3bd736 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -21,6 +21,8 @@ calls where one span is created for the gRPC call and a separate span is created for the underlying HTTP call in the event both gRPC and HTTP instrumentation are enabled. +* Renamed `ITextPropagator` to `IPropagator` + ([#1190](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1190)) ## 0.4.0-beta.2 diff --git a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md index 7113c93fe7a..37e2f745de0 100644 --- a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md @@ -18,6 +18,8 @@ Framework) `TracerProviderBuilderExtensions`. `AddHttpClientInstrumentation` will now register `HttpClient` instrumentation on .NET Core and `HttpClient` + `HttpWebRequest` instrumentation on .NET Framework. +* Renamed `ITextPropagator` to `IPropagator` + ([#1190](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1190)) ## 0.3.0-beta diff --git a/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md b/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md index 952aac4a905..9217644acd0 100644 --- a/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md +++ b/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Renamed `ITextPropagator` to `IPropagator` + ([#1190](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1190)) + ## 0.4.0-beta.2 Released 2020-07-24