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

Renaming TraceContextFormat/B3Format/BaggageFormat #1175

Merged
merged 5 commits into from
Aug 28, 2020
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
2 changes: 1 addition & 1 deletion examples/Console/TestOpenTracingWithConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal static object Run(OpenTracingShimOptions options)

// Following shows how to use the OpenTracing shim

var tracer = new TracerShim(TracerProvider.Default.GetTracer("MyCompany.MyProduct.MyWebServer"), new TraceContextFormat());
var tracer = new TracerShim(TracerProvider.Default.GetTracer("MyCompany.MyProduct.MyWebServer"), new TextMapPropagator());

using (IScope parentScope = tracer.BuildSpan("Parent").StartActive(finishSpanOnDispose: true))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 TraceContextFormat();
private static readonly ITextFormat TextFormat = new TextMapPropagator();

private readonly ILogger<MessageReceiver> logger;
private readonly IConnection connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 TraceContextFormat();
private static readonly ITextFormat TextFormat = new TextMapPropagator();

private readonly ILogger<MessageSender> logger;
private readonly IConnection connection;
Expand Down
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
API`](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/baggage/api.md)
spec
([#1106](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1106))
* Renamed `TraceContextFormat` to `TextMapPropagator`, `BaggageFormat` to
`BaggagePropagator`, and `B3Format` to `B3Propagator`
([#1175](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1175))

## 0.4.0-beta.2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="B3Format.cs" company="OpenTelemetry Authors">
// <copyright file="B3Propagator.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -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 B3Format : ITextFormat
public sealed class B3Propagator : ITextFormat
{
internal const string XB3TraceId = "X-B3-TraceId";
internal const string XB3SpanId = "X-B3-SpanId";
Expand All @@ -51,18 +51,18 @@ public sealed class B3Format : ITextFormat
private readonly bool singleHeader;

/// <summary>
/// Initializes a new instance of the <see cref="B3Format"/> class.
/// Initializes a new instance of the <see cref="B3Propagator"/> class.
/// </summary>
public B3Format()
public B3Propagator()
: this(false)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="B3Format"/> class.
/// Initializes a new instance of the <see cref="B3Propagator"/> class.
/// </summary>
/// <param name="singleHeader">Determines whether to use single or multiple headers when extracting or injecting span context.</param>
public B3Format(bool singleHeader)
public B3Propagator(bool singleHeader)
{
this.singleHeader = singleHeader;
}
Expand All @@ -81,13 +81,13 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func

if (carrier == null)
{
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(B3Format), "null carrier");
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(B3Propagator), "null carrier");
return context;
}

if (getter == null)
{
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(B3Format), "null getter");
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(B3Propagator), "null getter");
return context;
}

Expand All @@ -106,19 +106,19 @@ public void Inject<T>(PropagationContext context, T carrier, Action<T, string, s
{
if (context.ActivityContext.TraceId == default || context.ActivityContext.SpanId == default)
{
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(B3Format), "invalid context");
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(B3Propagator), "invalid context");
return;
}

if (carrier == null)
{
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(B3Format), "null carrier");
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(B3Propagator), "null carrier");
return;
}

if (setter == null)
{
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(B3Format), "null setter");
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(B3Propagator), "null setter");
return;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ private static PropagationContext ExtractFromMultipleHeaders<T>(PropagationConte
}
catch (Exception e)
{
OpenTelemetryApiEventSource.Log.ActivityContextExtractException(nameof(B3Format), e);
OpenTelemetryApiEventSource.Log.ActivityContextExtractException(nameof(B3Propagator), e);
return context;
}
}
Expand Down Expand Up @@ -252,7 +252,7 @@ private static PropagationContext ExtractFromSingleHeader<T>(PropagationContext
}
catch (Exception e)
{
OpenTelemetryApiEventSource.Log.ActivityContextExtractException(nameof(B3Format), e);
OpenTelemetryApiEventSource.Log.ActivityContextExtractException(nameof(B3Propagator), e);
return context;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="BaggageFormat.cs" company="OpenTelemetry Authors">
// <copyright file="BaggagePropagator.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -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 BaggageFormat : ITextFormat
public class BaggagePropagator : ITextFormat
{
internal const string BaggageHeaderName = "Baggage";

Expand All @@ -47,13 +47,13 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func

if (carrier == null)
{
OpenTelemetryApiEventSource.Log.FailedToExtractBaggage(nameof(BaggageFormat), "null carrier");
OpenTelemetryApiEventSource.Log.FailedToExtractBaggage(nameof(BaggagePropagator), "null carrier");
return context;
}

if (getter == null)
{
OpenTelemetryApiEventSource.Log.FailedToExtractBaggage(nameof(BaggageFormat), "null getter");
OpenTelemetryApiEventSource.Log.FailedToExtractBaggage(nameof(BaggagePropagator), "null getter");
return context;
}

Expand All @@ -72,7 +72,7 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func
}
catch (Exception ex)
{
OpenTelemetryApiEventSource.Log.BaggageExtractException(nameof(BaggageFormat), ex);
OpenTelemetryApiEventSource.Log.BaggageExtractException(nameof(BaggagePropagator), ex);
}

return context;
Expand All @@ -83,13 +83,13 @@ public void Inject<T>(PropagationContext context, T carrier, Action<T, string, s
{
if (carrier == null)
{
OpenTelemetryApiEventSource.Log.FailedToInjectBaggage(nameof(BaggageFormat), "null carrier");
OpenTelemetryApiEventSource.Log.FailedToInjectBaggage(nameof(BaggagePropagator), "null carrier");
return;
}

if (setter == null)
{
OpenTelemetryApiEventSource.Log.FailedToInjectBaggage(nameof(BaggageFormat), "null setter");
OpenTelemetryApiEventSource.Log.FailedToInjectBaggage(nameof(BaggagePropagator), "null setter");
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="TraceContextFormat.cs" company="OpenTelemetry Authors">
// <copyright file="TextMapPropagator.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -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 TraceContextFormat : ITextFormat
public class TextMapPropagator : ITextFormat
{
private const string TraceParent = "traceparent";
private const string TraceState = "tracestate";
Expand All @@ -53,13 +53,13 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func

if (carrier == null)
{
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(TraceContextFormat), "null carrier");
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(TextMapPropagator), "null carrier");
return context;
}

if (getter == null)
{
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(TraceContextFormat), "null getter");
OpenTelemetryApiEventSource.Log.FailedToExtractActivityContext(nameof(TextMapPropagator), "null getter");
return context;
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func
}
catch (Exception ex)
{
OpenTelemetryApiEventSource.Log.ActivityContextExtractException(nameof(TraceContextFormat), ex);
OpenTelemetryApiEventSource.Log.ActivityContextExtractException(nameof(TextMapPropagator), ex);
}

// in case of exception indicate to upstream that there is no parseable context from the top
Expand All @@ -106,19 +106,19 @@ public void Inject<T>(PropagationContext context, T carrier, Action<T, string, s
{
if (context.ActivityContext.TraceId == default || context.ActivityContext.SpanId == default)
{
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(TraceContextFormat), "Invalid context");
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(TextMapPropagator), "Invalid context");
return;
}

if (carrier == null)
{
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(TraceContextFormat), "null carrier");
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(TextMapPropagator), "null carrier");
return;
}

if (setter == null)
{
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(TraceContextFormat), "null setter");
OpenTelemetryApiEventSource.Log.FailedToInjectActivityContext(nameof(TextMapPropagator), "null setter");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ 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="TraceContextFormat"/> &amp; <see cref="BaggageFormat"/>.
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> &amp; <see cref="BaggagePropagator"/>.
/// </summary>
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
{
new TraceContextFormat(),
new BaggageFormat(),
new TextMapPropagator(),
new BaggagePropagator(),
});

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override void OnStartActivity(Activity activity, object payload)
var request = context.Request;
var requestValues = request.Unvalidated;

if (!(this.options.TextFormat is TraceContextFormat))
if (!(this.options.TextFormat is TextMapPropagator))
{
var ctx = this.options.TextFormat.Extract(default, request, HttpRequestHeaderValuesGetter);

Expand Down Expand Up @@ -125,7 +125,7 @@ public override void OnStopActivity(Activity activity, object payload)
Activity activityToEnrich = activity;
Activity createdActivity = null;

if (!(this.options.TextFormat is TraceContextFormat))
if (!(this.options.TextFormat is TextMapPropagator))
{
// If using custom context propagator, then the activity here
// could be either the one from Asp.Net, or the one
Expand Down Expand Up @@ -190,7 +190,7 @@ public override void OnStopActivity(Activity activity, object payload)
}
}

if (!(this.options.TextFormat is TraceContextFormat))
if (!(this.options.TextFormat is TextMapPropagator))
{
if (activity.OperationName.Equals(ActivityNameByHttpInListener))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ 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="TraceContextFormat"/> &amp; <see cref="BaggageFormat"/>.
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> &amp; <see cref="BaggagePropagator"/>.
/// </summary>
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
{
new TraceContextFormat(),
new BaggageFormat(),
new TextMapPropagator(),
new BaggagePropagator(),
});

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override void OnStartActivity(Activity activity, object payload)
}

var request = context.Request;
if (!this.hostingSupportsW3C || !(this.options.TextFormat is TraceContextFormat))
if (!this.hostingSupportsW3C || !(this.options.TextFormat is TextMapPropagator))
{
var ctx = this.options.TextFormat.Extract(default, request, HttpRequestHeaderValuesGetter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Net.Http;
using System.Runtime.CompilerServices;
Expand All @@ -32,12 +33,12 @@ public class HttpClientInstrumentationOptions
public bool SetHttpFlavor { get; set; }

/// <summary>
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TraceContextFormat"/> &amp; <see cref="BaggageFormat"/>.
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> &amp; <see cref="BaggagePropagator"/>.
/// </summary>
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
{
new TraceContextFormat(),
new BaggageFormat(),
new TextMapPropagator(),
new BaggagePropagator(),
});

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

#if NETFRAMEWORK
using System;
using System.Net;
Expand All @@ -32,12 +33,12 @@ public class HttpWebRequestInstrumentationOptions
public bool SetHttpFlavor { get; set; }

/// <summary>
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TraceContextFormat"/> &amp; <see cref="BaggageFormat"/>.
/// Gets or sets <see cref="ITextFormat"/> for context propagation. Default value: <see cref="CompositePropagator"/> with <see cref="TextMapPropagator"/> &amp; <see cref="BaggagePropagator"/>.
/// </summary>
public ITextFormat TextFormat { get; set; } = new CompositePropagator(new ITextFormat[]
{
new TraceContextFormat(),
new BaggageFormat(),
new TextMapPropagator(),
new BaggagePropagator(),
});

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public override void OnStartActivity(Activity activity, object payload)
}
}

if (!(this.httpClientSupportsW3C && this.options.TextFormat is TraceContextFormat))
if (!(this.httpClientSupportsW3C && this.options.TextFormat is TextMapPropagator))
{
this.options.TextFormat.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpRequestMessageHeaderValueSetter);
}
Expand Down
Loading