Skip to content

Commit

Permalink
Rename of Propagators (#1427)
Browse files Browse the repository at this point in the history
* Rename IPropagator to ITextMapPropagator, TextMapPropagator to TraceContextPropagator

* changelogs

* build fix

* make ITextMapPropagator an abstract class

* Renaming ITextMapPropagator to TextMapPropagator

* CompositeTextMapPropagator rename

* fix changhelog
  • Loading branch information
cijothomas authored Oct 30, 2020
1 parent be5a7a7 commit 4975fb0
Show file tree
Hide file tree
Showing 30 changed files with 393 additions and 369 deletions.
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 TextMapPropagator());
var tracer = new TracerShim(TracerProvider.Default.GetTracer("MyCompany.MyProduct.MyWebServer"), new TraceContextPropagator());

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 IPropagator Propagator = new TextMapPropagator();
private static readonly TextMapPropagator Propagator = new TraceContextPropagator();

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 IPropagator Propagator = new TextMapPropagator();
private static readonly TextMapPropagator Propagator = new TraceContextPropagator();

private readonly ILogger<MessageSender> logger;
private readonly IConnection connection;
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* `B3Propagator` now supports the value `true` to be passed in for the header
`X-B3-Sampled`.
([#1413](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1413))
* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor
to CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator
and changed from interface to abstract class.
([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1427))

## 0.7.0-beta.1

Expand Down
10 changes: 5 additions & 5 deletions src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
namespace OpenTelemetry.Context.Propagation
{
/// <summary>
/// B3 text propagator. See https://github.com/openzipkin/b3-propagation for the specification.
/// A text map propagator for B3. See https://github.com/openzipkin/b3-propagation.
/// </summary>
public sealed class B3Propagator : IPropagator
public sealed class B3Propagator : TextMapPropagator
{
internal const string XB3TraceId = "X-B3-TraceId";
internal const string XB3SpanId = "X-B3-SpanId";
Expand Down Expand Up @@ -73,10 +73,10 @@ public B3Propagator(bool singleHeader)
}

/// <inheritdoc/>
public ISet<string> Fields => AllFields;
public override ISet<string> Fields => AllFields;

/// <inheritdoc/>
public PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
public override PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
{
if (context.ActivityContext.IsValid())
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func
}

/// <inheritdoc/>
public void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
public override void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
{
if (context.ActivityContext.TraceId == default || context.ActivityContext.SpanId == default)
{
Expand Down
10 changes: 5 additions & 5 deletions src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
namespace OpenTelemetry.Context.Propagation
{
/// <summary>
/// W3C baggage: https://github.com/w3c/baggage/blob/master/baggage/HTTP_HEADER_FORMAT.md.
/// A text map propagator for W3C Baggage. See https://w3c.github.io/baggage/.
/// </summary>
public class BaggagePropagator : IPropagator
public class BaggagePropagator : TextMapPropagator
{
internal const string BaggageHeaderName = "Baggage";

private const int MaxBaggageLength = 8192;
private const int MaxBaggageItems = 180;

/// <inheritdoc/>
public ISet<string> Fields => new HashSet<string> { BaggageHeaderName };
public override ISet<string> Fields => new HashSet<string> { BaggageHeaderName };

/// <inheritdoc/>
public PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
public override PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
{
if (context.Baggage != default)
{
Expand Down Expand Up @@ -79,7 +79,7 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func
}

/// <inheritdoc/>
public void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
public override void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
{
if (carrier == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="CompositePropagator.cs" company="OpenTelemetry Authors">
// <copyright file="CompositeTextMapPropagator.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,27 +20,28 @@
namespace OpenTelemetry.Context.Propagation
{
/// <summary>
/// CompositePropagator provides a mechanism for combining multiple propagators into a single one.
/// CompositeTextMapPropagator provides a mechanism for combining multiple
/// textmap propagators into a single one.
/// </summary>
public class CompositePropagator : IPropagator
public class CompositeTextMapPropagator : TextMapPropagator
{
private static readonly ISet<string> EmptyFields = new HashSet<string>();
private readonly List<IPropagator> propagators;
private readonly List<TextMapPropagator> propagators;

/// <summary>
/// Initializes a new instance of the <see cref="CompositePropagator"/> class.
/// Initializes a new instance of the <see cref="CompositeTextMapPropagator"/> class.
/// </summary>
/// <param name="propagators">List of <see cref="IPropagator"/> wire context propagator.</param>
public CompositePropagator(IEnumerable<IPropagator> propagators)
/// <param name="propagators">List of <see cref="TextMapPropagator"/> wire context propagator.</param>
public CompositeTextMapPropagator(IEnumerable<TextMapPropagator> propagators)
{
this.propagators = new List<IPropagator>(propagators ?? throw new ArgumentNullException(nameof(propagators)));
this.propagators = new List<TextMapPropagator>(propagators ?? throw new ArgumentNullException(nameof(propagators)));
}

/// <inheritdoc/>
public ISet<string> Fields => EmptyFields;
public override ISet<string> Fields => EmptyFields;

/// <inheritdoc/>
public PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
public override PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
{
foreach (var propagator in this.propagators)
{
Expand All @@ -51,7 +52,7 @@ public PropagationContext Extract<T>(PropagationContext context, T carrier, Func
}

/// <inheritdoc/>
public void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
public override void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter)
{
foreach (var propagator in this.propagators)
{
Expand Down
54 changes: 0 additions & 54 deletions src/OpenTelemetry.Api/Context/Propagation/IPropagator.cs

This file was deleted.

Loading

0 comments on commit 4975fb0

Please sign in to comment.