Renaming ITextFormat to IPropagator (#1190)
* Renaming ITextFormat to IPropagator * updating changelog Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
187cf528a6
commit
dd4bd3e0bd
|
|
@ -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<MessageReceiver> logger;
|
||||
private readonly IConnection connection;
|
||||
|
|
@ -57,7 +57,7 @@ namespace Utils.Messaging
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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<MessageSender> logger;
|
||||
private readonly IConnection connection;
|
||||
|
|
@ -62,7 +62,7 @@ namespace Utils.Messaging
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <summary>
|
||||
/// B3 text propagator. See https://github.com/openzipkin/b3-propagation for the specification.
|
||||
/// </summary>
|
||||
public sealed class B3Propagator : ITextFormat
|
||||
public sealed class B3Propagator : IPropagator
|
||||
{
|
||||
internal const string XB3TraceId = "X-B3-TraceId";
|
||||
internal const string XB3SpanId = "X-B3-SpanId";
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <summary>
|
||||
/// W3C baggage: https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md.
|
||||
/// </summary>
|
||||
public class BaggagePropagator : ITextFormat
|
||||
public class BaggagePropagator : IPropagator
|
||||
{
|
||||
internal const string BaggageHeaderName = "Baggage";
|
||||
|
||||
|
|
|
|||
|
|
@ -22,18 +22,18 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <summary>
|
||||
/// CompositePropagator provides a mechanism for combining multiple propagators into a single one.
|
||||
/// </summary>
|
||||
public class CompositePropagator : ITextFormat
|
||||
public class CompositePropagator : IPropagator
|
||||
{
|
||||
private static readonly ISet<string> EmptyFields = new HashSet<string>();
|
||||
private readonly List<ITextFormat> textFormats;
|
||||
private readonly List<IPropagator> propagators;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CompositePropagator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="textFormats">List of <see cref="ITextFormat"/> wire context propagator.</param>
|
||||
public CompositePropagator(IEnumerable<ITextFormat> textFormats)
|
||||
/// <param name="propagators">List of <see cref="IPropagator"/> wire context propagator.</param>
|
||||
public CompositePropagator(IEnumerable<IPropagator> propagators)
|
||||
{
|
||||
this.textFormats = new List<ITextFormat>(textFormats ?? throw new ArgumentNullException(nameof(textFormats)));
|
||||
this.propagators = new List<IPropagator>(propagators ?? throw new ArgumentNullException(nameof(propagators)));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
@ -42,9 +42,9 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <inheritdoc/>
|
||||
public PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> 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 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <inheritdoc/>
|
||||
public void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
|
||||
{
|
||||
foreach (var textFormat in this.textFormats)
|
||||
foreach (var propagator in this.propagators)
|
||||
{
|
||||
textFormat.Inject(context, carrier, setter);
|
||||
propagator.Inject(context, carrier, setter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="ITextFormat.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="IPropagator.cs" company="OpenTelemetry Authors">
|
||||
// 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).
|
||||
/// </summary>
|
||||
public interface ITextFormat
|
||||
public interface IPropagator
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the list of headers used by propagator. The use cases of this are:
|
||||
|
|
@ -26,7 +26,7 @@ namespace OpenTelemetry.Context.Propagation
|
|||
/// <summary>
|
||||
/// W3C trace context text wire protocol formatter. See https://github.com/w3c/distributed-tracing/.
|
||||
/// </summary>
|
||||
public class TextMapPropagator : ITextFormat
|
||||
public class TextMapPropagator : IPropagator
|
||||
{
|
||||
private const string TraceParent = "traceparent";
|
||||
private const string TraceState = "tracestate";
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ namespace OpenTelemetry.Instrumentation.AspNet
|
|||
public class AspNetInstrumentationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// Gets or sets <see cref="IPropagator"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// </summary>
|
||||
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
|
||||
public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[]
|
||||
{
|
||||
new TextMapPropagator(),
|
||||
new BaggagePropagator(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation
|
|||
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 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation
|
|||
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 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation
|
|||
}
|
||||
}
|
||||
|
||||
if (!(this.options.TextFormat is TextMapPropagator))
|
||||
if (!(this.options.Propagator is TextMapPropagator))
|
||||
{
|
||||
if (activity.OperationName.Equals(ActivityNameByHttpInListener))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ namespace OpenTelemetry.Instrumentation.AspNetCore
|
|||
public class AspNetCoreInstrumentationOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// Gets or sets <see cref="IPropagator"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// </summary>
|
||||
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
|
||||
public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[]
|
||||
{
|
||||
new TextMapPropagator(),
|
||||
new BaggagePropagator(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ namespace OpenTelemetry.Instrumentation.Http
|
|||
public bool SetHttpFlavor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// Gets or sets <see cref="IPropagator"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// </summary>
|
||||
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
|
||||
public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[]
|
||||
{
|
||||
new TextMapPropagator(),
|
||||
new BaggagePropagator(),
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ namespace OpenTelemetry.Instrumentation.Http
|
|||
public bool SetHttpFlavor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// Gets or sets <see cref="IPropagator"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> & <see cref="BaggagePropagator"/>.
|
||||
/// </summary>
|
||||
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
|
||||
public IPropagator Propagator { get; set; } = new CompositePropagator(new IPropagator[]
|
||||
{
|
||||
new TextMapPropagator(),
|
||||
new BaggagePropagator(),
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
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 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,11 +190,11 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
|
|||
|
||||
[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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
return value;
|
||||
}
|
||||
|
||||
propagationContext = this.textFormat.Extract(propagationContext, carrierMap, GetCarrierKeyValue);
|
||||
propagationContext = this.propagator.Extract(propagationContext, carrierMap, GetCarrierKeyValue);
|
||||
}
|
||||
|
||||
// TODO:
|
||||
|
|
@ -120,7 +119,7 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -128,8 +128,8 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests
|
|||
|
||||
var expectedTraceId = ActivityTraceId.CreateRandom();
|
||||
var expectedSpanId = ActivitySpanId.CreateRandom();
|
||||
var textFormat = new Mock<ITextFormat>();
|
||||
textFormat.Setup(m => m.Extract<HttpRequest>(It.IsAny<PropagationContext>(), It.IsAny<HttpRequest>(), It.IsAny<Func<HttpRequest, string, IEnumerable<string>>>())).Returns(new PropagationContext(
|
||||
var propagator = new Mock<IPropagator>();
|
||||
propagator.Setup(m => m.Extract<HttpRequest>(It.IsAny<PropagationContext>(), It.IsAny<HttpRequest>(), It.IsAny<Func<HttpRequest, string, IEnumerable<string>>>())).Returns(new PropagationContext(
|
||||
new ActivityContext(
|
||||
expectedTraceId,
|
||||
expectedSpanId,
|
||||
|
|
@ -160,7 +160,7 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests
|
|||
|
||||
if (!carrierFormat.Equals("TraceContext"))
|
||||
{
|
||||
options.TextFormat = textFormat.Object;
|
||||
options.Propagator = propagator.Object;
|
||||
}
|
||||
})
|
||||
.SetResource(expectedResource)
|
||||
|
|
|
|||
|
|
@ -136,15 +136,15 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CustomTextFormat()
|
||||
public async Task CustomPropagator()
|
||||
{
|
||||
var activityProcessor = new Mock<ActivityProcessor>();
|
||||
|
||||
var expectedTraceId = ActivityTraceId.CreateRandom();
|
||||
var expectedSpanId = ActivitySpanId.CreateRandom();
|
||||
|
||||
var textFormat = new Mock<ITextFormat>();
|
||||
textFormat.Setup(m => m.Extract(It.IsAny<PropagationContext>(), It.IsAny<HttpRequest>(), It.IsAny<Func<HttpRequest, string, IEnumerable<string>>>())).Returns(
|
||||
var propagator = new Mock<IPropagator>();
|
||||
propagator.Setup(m => m.Extract(It.IsAny<PropagationContext>(), It.IsAny<HttpRequest>(), It.IsAny<Func<HttpRequest, string, IEnumerable<string>>>())).Returns(
|
||||
new PropagationContext(
|
||||
new ActivityContext(
|
||||
expectedTraceId,
|
||||
|
|
@ -158,7 +158,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
builder.ConfigureTestServices(services =>
|
||||
{
|
||||
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
|
||||
.AddAspNetCoreInstrumentation((opt) => opt.TextFormat = textFormat.Object)
|
||||
.AddAspNetCoreInstrumentation((opt) => opt.Propagator = propagator.Object)
|
||||
.AddProcessor(activityProcessor.Object)
|
||||
.Build();
|
||||
})))
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
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<ITextFormat>();
|
||||
var mockPropagator = new Mock<IPropagator>();
|
||||
|
||||
// var isInjectedHeaderValueGetterThrows = false;
|
||||
// mockTextFormat
|
||||
|
|
@ -93,7 +93,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
// });
|
||||
|
||||
using (Sdk.CreateTracerProviderBuilder()
|
||||
.AddHttpClientInstrumentation(o => o.TextFormat = mockTextFormat.Object)
|
||||
.AddHttpClientInstrumentation(o => o.Propagator = mockPropagator.Object)
|
||||
.AddProcessor(processor.Object)
|
||||
.Build())
|
||||
{
|
||||
|
|
@ -122,8 +122,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
[Fact]
|
||||
public async Task HttpClientInstrumentationInjectsHeadersAsync_CustomFormat()
|
||||
{
|
||||
var textFormat = new Mock<ITextFormat>();
|
||||
textFormat.Setup(m => m.Inject<HttpRequestMessage>(It.IsAny<PropagationContext>(), It.IsAny<HttpRequestMessage>(), It.IsAny<Action<HttpRequestMessage, string, string>>()))
|
||||
var propagator = new Mock<IPropagator>();
|
||||
propagator.Setup(m => m.Inject<HttpRequestMessage>(It.IsAny<PropagationContext>(), It.IsAny<HttpRequestMessage>(), It.IsAny<Action<HttpRequestMessage, string, string>>()))
|
||||
.Callback<PropagationContext, HttpRequestMessage, Action<HttpRequestMessage, string, string>>((context, message, action) =>
|
||||
{
|
||||
action(message, "custom_traceparent", $"00/{context.ActivityContext.TraceId}/{context.ActivityContext.SpanId}/01");
|
||||
|
|
@ -145,7 +145,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
parent.ActivityTraceFlags = ActivityTraceFlags.Recorded;
|
||||
|
||||
using (Sdk.CreateTracerProviderBuilder()
|
||||
.AddHttpClientInstrumentation((opt) => opt.TextFormat = textFormat.Object)
|
||||
.AddHttpClientInstrumentation((opt) => opt.Propagator = propagator.Object)
|
||||
.AddProcessor(processor.Object)
|
||||
.Build())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
[Fact]
|
||||
public async Task HttpWebRequestInstrumentationInjectsHeadersAsync_CustomFormat()
|
||||
{
|
||||
var textFormat = new Mock<ITextFormat>();
|
||||
textFormat.Setup(m => m.Inject(It.IsAny<PropagationContext>(), It.IsAny<HttpWebRequest>(), It.IsAny<Action<HttpWebRequest, string, string>>()))
|
||||
var propagator = new Mock<IPropagator>();
|
||||
propagator.Setup(m => m.Inject(It.IsAny<PropagationContext>(), It.IsAny<HttpWebRequest>(), It.IsAny<Action<HttpWebRequest, string, string>>()))
|
||||
.Callback<PropagationContext, HttpWebRequest, Action<HttpWebRequest, string, string>>((context, message, action) =>
|
||||
{
|
||||
action(message, "custom_traceparent", $"00/{context.ActivityContext.TraceId}/{context.ActivityContext.SpanId}/01");
|
||||
|
|
@ -109,7 +109,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
var activityProcessor = new Mock<ActivityProcessor>();
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace OpenTelemetry.Context.Propagation.Tests
|
|||
[Fact]
|
||||
public void CompositePropagator_TestPropagator()
|
||||
{
|
||||
var compositePropagator = new CompositePropagator(new List<ITextFormat>
|
||||
var compositePropagator = new CompositePropagator(new List<IPropagator>
|
||||
{
|
||||
new TestPropagator("custom-traceparent-1", "custom-tracestate-1"),
|
||||
new TestPropagator("custom-traceparent-2", "custom-tracestate-2"),
|
||||
|
|
@ -77,7 +77,7 @@ namespace OpenTelemetry.Context.Propagation.Tests
|
|||
const string header01 = "custom-tracestate-01";
|
||||
const string header02 = "custom-tracestate-02";
|
||||
|
||||
var compositePropagator = new CompositePropagator(new List<ITextFormat>
|
||||
var compositePropagator = new CompositePropagator(new List<IPropagator>
|
||||
{
|
||||
new TestPropagator("custom-traceparent", header01, true),
|
||||
new TestPropagator("custom-traceparent", header02),
|
||||
|
|
@ -106,7 +106,7 @@ namespace OpenTelemetry.Context.Propagation.Tests
|
|||
[Fact]
|
||||
public void CompositePropagator_ActivityContext_Baggage()
|
||||
{
|
||||
var compositePropagator = new CompositePropagator(new List<ITextFormat>
|
||||
var compositePropagator = new CompositePropagator(new List<IPropagator>
|
||||
{
|
||||
new TextMapPropagator(),
|
||||
new BaggagePropagator(),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ using System.Linq;
|
|||
|
||||
namespace OpenTelemetry.Context.Propagation.Tests
|
||||
{
|
||||
public class TestPropagator : ITextFormat
|
||||
public class TestPropagator : IPropagator
|
||||
{
|
||||
private readonly string idHeaderName;
|
||||
private readonly string stateHeaderName;
|
||||
|
|
|
|||
Loading…
Reference in New Issue