Remove propagators from tracing API (#466)
This commit is contained in:
parent
9ddcc0adcc
commit
85e589a6fc
|
|
@ -40,12 +40,6 @@ namespace LoggingTracer
|
|||
/// <inheritdoc/>
|
||||
public override ISpan CurrentSpan => CurrentSpanUtils.CurrentSpan;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IBinaryFormat BinaryFormat => new LoggingBinaryFormat();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ITextFormat TextFormat => new LoggingTextFormat();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IDisposable WithSpan(ISpan span, bool endOnDispose)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,20 +28,12 @@ namespace OpenTelemetry.Trace
|
|||
internal sealed class ProxyTracer : Tracer
|
||||
{
|
||||
private static readonly IDisposable NoopScope = new NoopDisposable();
|
||||
private readonly IBinaryFormat binaryFormat = new BinaryFormat();
|
||||
private readonly ITextFormat textFormat = new TraceContextFormat();
|
||||
|
||||
private Tracer realTracer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ISpan CurrentSpan => this.realTracer?.CurrentSpan ?? BlankSpan.Instance;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IBinaryFormat BinaryFormat => this.realTracer?.BinaryFormat ?? this.binaryFormat;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ITextFormat TextFormat => this.realTracer?.TextFormat ?? this.textFormat;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IDisposable WithSpan(ISpan span, bool endOnDispose)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
|
||||
namespace OpenTelemetry.Trace
|
||||
{
|
||||
|
|
@ -31,16 +30,6 @@ namespace OpenTelemetry.Trace
|
|||
/// </summary>
|
||||
public abstract ISpan CurrentSpan { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IBinaryFormat"/> for this implementation.
|
||||
/// </summary>
|
||||
public abstract IBinaryFormat BinaryFormat { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ITextFormat"/> for this implementation.
|
||||
/// </summary>
|
||||
public abstract ITextFormat TextFormat { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Activates the span on the current context.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
// </copyright>
|
||||
using System;
|
||||
using OpenTelemetry.Collector.AspNetCore.Implementation;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Collector.AspNetCore
|
||||
|
|
@ -42,7 +43,7 @@ namespace OpenTelemetry.Collector.AspNetCore
|
|||
/// <param name="options">Configuration options for dependencies collector.</param>
|
||||
public AspNetCoreCollector(Tracer tracer, AspNetCoreCollectorOptions options)
|
||||
{
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", tracer, options.RequestFilter), null);
|
||||
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", tracer, options), null);
|
||||
this.diagnosticSourceSubscriber.Subscribe();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
|
||||
namespace OpenTelemetry.Collector.AspNetCore
|
||||
{
|
||||
|
|
@ -24,6 +25,11 @@ namespace OpenTelemetry.Collector.AspNetCore
|
|||
/// </summary>
|
||||
public class AspNetCoreCollectorOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets <see cref="ITextFormat"/> for context propagation.
|
||||
/// </summary>
|
||||
public ITextFormat TextFormat { get; set; } = new TraceContextFormat();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a hook to exclude calls based on domain or other per-request criterion.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
|||
private readonly PropertyFetcher beforeActionAttributeRouteInfoFetcher = new PropertyFetcher("AttributeRouteInfo");
|
||||
private readonly PropertyFetcher beforeActionTemplateFetcher = new PropertyFetcher("Template");
|
||||
private readonly bool hostingSupportsW3C = false;
|
||||
private readonly Predicate<HttpContext> requestFilter;
|
||||
private readonly AspNetCoreCollectorOptions options;
|
||||
|
||||
public HttpInListener(string name, Tracer tracer, Predicate<HttpContext> requestFilter)
|
||||
public HttpInListener(string name, Tracer tracer, AspNetCoreCollectorOptions options)
|
||||
: base(name, tracer)
|
||||
{
|
||||
this.hostingSupportsW3C = typeof(HttpRequest).Assembly.GetName().Version.Major >= 3;
|
||||
this.requestFilter = requestFilter;
|
||||
this.options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
public override void OnStartActivity(Activity activity, object payload)
|
||||
|
|
@ -54,7 +54,7 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.requestFilter != null && !this.requestFilter(context))
|
||||
if (this.options.RequestFilter != null && !this.options.RequestFilter(context))
|
||||
{
|
||||
CollectorEventSource.Log.RequestIsFilteredOut(activity.OperationName);
|
||||
return;
|
||||
|
|
@ -66,13 +66,13 @@ namespace OpenTelemetry.Collector.AspNetCore.Implementation
|
|||
var path = (request.PathBase.HasValue || request.Path.HasValue) ? (request.PathBase + request.Path).ToString() : "/";
|
||||
|
||||
ISpan span;
|
||||
if (this.hostingSupportsW3C && this.Tracer.TextFormat is TraceContextFormat)
|
||||
if (this.hostingSupportsW3C && this.options.TextFormat is TraceContextFormat)
|
||||
{
|
||||
this.Tracer.StartActiveSpanFromActivity(path, Activity.Current, SpanKind.Server, out span);
|
||||
}
|
||||
else
|
||||
{
|
||||
var ctx = this.Tracer.TextFormat.Extract<HttpRequest>(
|
||||
var ctx = this.options.TextFormat.Extract<HttpRequest>(
|
||||
request,
|
||||
(r, name) => r.Headers[name]);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace OpenTelemetry.Collector.Dependencies
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DependenciesCollector"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">Configuraiton options.</param>
|
||||
/// <param name="options">Configuration options.</param>
|
||||
/// <param name="tracerFactory">Tracer factory to get a tracer from.</param>
|
||||
public DependenciesCollector(HttpClientCollectorOptions options, TracerFactoryBase tracerFactory)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
// </copyright>
|
||||
using System;
|
||||
using OpenTelemetry.Collector.Dependencies.Implementation;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
namespace OpenTelemetry.Collector.Dependencies
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
// </copyright>
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
|
||||
namespace OpenTelemetry.Collector.Dependencies
|
||||
{
|
||||
|
|
@ -47,6 +48,11 @@ namespace OpenTelemetry.Collector.Dependencies
|
|||
/// </summary>
|
||||
public bool SetHttpFlavor { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets <see cref="ITextFormat"/> for context propagation.
|
||||
/// </summary>
|
||||
public ITextFormat TextFormat { get; set; } = new TraceContextFormat();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a hook to exclude calls based on domain or other per-request criterion.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
// </copyright>
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
|
|
@ -84,9 +83,9 @@ namespace OpenTelemetry.Collector.Dependencies.Implementation
|
|||
}
|
||||
}
|
||||
|
||||
if (!(this.httpClientSupportsW3C && this.Tracer.TextFormat is TraceContextFormat))
|
||||
if (!(this.httpClientSupportsW3C && this.options.TextFormat is TraceContextFormat))
|
||||
{
|
||||
this.Tracer.TextFormat.Inject<HttpRequestMessage>(span.Context, request, (r, k, v) => r.Headers.Add(k, v));
|
||||
this.options.TextFormat.Inject<HttpRequestMessage>(span.Context, request, (r, k, v) => r.Headers.Add(k, v));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using global::OpenTracing.Propagation;
|
||||
using OpenTelemetry.Context.Propagation;
|
||||
|
||||
namespace OpenTelemetry.Shims.OpenTracing
|
||||
{
|
||||
public class TracerShim : global::OpenTracing.ITracer
|
||||
{
|
||||
private readonly Trace.Tracer tracer;
|
||||
private readonly ITextFormat textFormat;
|
||||
private readonly IBinaryFormat binaryFormat;
|
||||
|
||||
private TracerShim(Trace.Tracer tracer)
|
||||
public TracerShim(Trace.Tracer tracer, ITextFormat textFormat, IBinaryFormat binaryFormat)
|
||||
{
|
||||
this.tracer = tracer ?? throw new ArgumentNullException(nameof(tracer));
|
||||
this.textFormat = textFormat ?? throw new ArgumentNullException(nameof(textFormat));
|
||||
this.binaryFormat = binaryFormat ?? throw new ArgumentNullException(nameof(binaryFormat));
|
||||
|
||||
this.ScopeManager = new ScopeManagerShim(this.tracer);
|
||||
}
|
||||
|
||||
|
|
@ -36,11 +42,6 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
/// <inheritdoc/>
|
||||
public global::OpenTracing.ISpan ActiveSpan => this.ScopeManager.Active?.Span;
|
||||
|
||||
public static global::OpenTracing.ITracer Create(Trace.Tracer tracer)
|
||||
{
|
||||
return new TracerShim(tracer);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public global::OpenTracing.ISpanBuilder BuildSpan(string operationName)
|
||||
{
|
||||
|
|
@ -81,17 +82,14 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
return value;
|
||||
}
|
||||
|
||||
if (this.tracer.TextFormat != null)
|
||||
{
|
||||
spanContext = this.tracer.TextFormat.Extract(carrierMap, GetCarrierKeyValue);
|
||||
}
|
||||
spanContext = this.textFormat.Extract(carrierMap, GetCarrierKeyValue);
|
||||
}
|
||||
else if (format == BuiltinFormats.Binary && carrier is IBinary binaryCarrier)
|
||||
{
|
||||
var ms = binaryCarrier.Get();
|
||||
if (ms != null && this.tracer.BinaryFormat != null)
|
||||
if (ms != null)
|
||||
{
|
||||
spanContext = this.tracer.BinaryFormat.FromByteArray(ms.ToArray());
|
||||
spanContext = this.binaryFormat.FromByteArray(ms.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,11 +124,11 @@ namespace OpenTelemetry.Shims.OpenTracing
|
|||
|
||||
if ((format == BuiltinFormats.TextMap || format == BuiltinFormats.HttpHeaders) && carrier is ITextMap textMapCarrier)
|
||||
{
|
||||
this.tracer.TextFormat?.Inject(shim.SpanContext, textMapCarrier, (adapter, key, value) => adapter.Set(key, value));
|
||||
this.textFormat.Inject(shim.SpanContext, textMapCarrier, (adapter, key, value) => adapter.Set(key, value));
|
||||
}
|
||||
else if (format == BuiltinFormats.Binary && carrier is IBinary binaryCarrier)
|
||||
{
|
||||
var bytes = this.tracer.BinaryFormat?.ToByteArray(shim.SpanContext);
|
||||
var bytes = this.binaryFormat.ToByteArray(shim.SpanContext);
|
||||
if (bytes != null)
|
||||
{
|
||||
binaryCarrier.Set(new System.IO.MemoryStream(bytes));
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@ namespace OpenTelemetry.Trace.Configuration
|
|||
|
||||
internal List<SpanProcessorPipelineBuilder> ProcessingPipelines { get; private set; }
|
||||
|
||||
internal IBinaryFormat BinaryFormat { get; private set; }
|
||||
|
||||
internal ITextFormat TextFormat { get; private set; }
|
||||
|
||||
internal List<CollectorFactory> CollectorFactories { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -124,26 +120,6 @@ namespace OpenTelemetry.Trace.Configuration
|
|||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures <see cref="ITextFormat"/> on the tracerSdk.
|
||||
/// </summary>
|
||||
/// <param name="textFormat"><see cref="ITextFormat"/> implementation class instance.</param>
|
||||
public TracerBuilder SetTextFormat(ITextFormat textFormat)
|
||||
{
|
||||
this.TextFormat = textFormat ?? throw new ArgumentNullException(nameof(textFormat));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures <see cref="IBinaryFormat"/> on the tracerSdk.
|
||||
/// </summary>
|
||||
/// <param name="binaryFormat"><see cref="IBinaryFormat"/> implementation class instance.</param>
|
||||
public TracerBuilder SetBinaryFormat(IBinaryFormat binaryFormat)
|
||||
{
|
||||
this.BinaryFormat = binaryFormat ?? throw new ArgumentNullException(nameof(binaryFormat));
|
||||
return this;
|
||||
}
|
||||
|
||||
internal readonly struct CollectorFactory
|
||||
{
|
||||
public readonly string Name;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ namespace OpenTelemetry.Trace.Configuration
|
|||
private readonly Resource defaultResource;
|
||||
private readonly TracerConfiguration configurationOptions;
|
||||
private readonly SpanProcessor spanProcessor;
|
||||
private readonly IBinaryFormat binaryFormat;
|
||||
private readonly ITextFormat textFormat;
|
||||
|
||||
private Tracer defaultTracer;
|
||||
|
||||
|
|
@ -73,15 +71,10 @@ namespace OpenTelemetry.Trace.Configuration
|
|||
this.spanProcessor = new BroadcastProcessor(processors);
|
||||
}
|
||||
|
||||
this.binaryFormat = builder.BinaryFormat ?? new BinaryFormat();
|
||||
this.textFormat = builder.TextFormat ?? new TraceContextFormat();
|
||||
|
||||
this.defaultTracer = new TracerSdk(
|
||||
this.spanProcessor,
|
||||
this.sampler,
|
||||
this.configurationOptions,
|
||||
this.binaryFormat,
|
||||
this.textFormat,
|
||||
this.defaultResource);
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +121,6 @@ namespace OpenTelemetry.Trace.Configuration
|
|||
this.spanProcessor,
|
||||
this.sampler,
|
||||
this.configurationOptions,
|
||||
this.binaryFormat,
|
||||
this.textFormat,
|
||||
this.defaultResource.Merge(new Resource(CreateLibraryResourceLabels(name, version))));
|
||||
this.tracerRegistry.Add(key, tracer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,15 +43,11 @@ namespace OpenTelemetry.Trace
|
|||
/// <param name="spanProcessor">Span processor.</param>
|
||||
/// <param name="sampler">Sampler to use.</param>
|
||||
/// <param name="tracerConfiguration">Trace configuration.</param>
|
||||
/// <param name="binaryFormat">Binary format context propagator.</param>
|
||||
/// <param name="textFormat">Text format context propagator.</param>
|
||||
/// <param name="libraryResource">Resource describing the instrumentation library.</param>
|
||||
internal TracerSdk(SpanProcessor spanProcessor, Sampler sampler, TracerConfiguration tracerConfiguration, IBinaryFormat binaryFormat, ITextFormat textFormat, Resource libraryResource)
|
||||
internal TracerSdk(SpanProcessor spanProcessor, Sampler sampler, TracerConfiguration tracerConfiguration, Resource libraryResource)
|
||||
{
|
||||
this.spanProcessor = spanProcessor ?? throw new ArgumentNullException(nameof(spanProcessor));
|
||||
this.tracerConfiguration = tracerConfiguration ?? throw new ArgumentNullException(nameof(tracerConfiguration));
|
||||
this.BinaryFormat = binaryFormat ?? throw new ArgumentNullException(nameof(binaryFormat));
|
||||
this.TextFormat = textFormat ?? throw new ArgumentNullException(nameof(textFormat));
|
||||
this.LibraryResource = libraryResource ?? throw new ArgumentNullException(nameof(libraryResource));
|
||||
this.sampler = sampler ?? throw new ArgumentNullException(nameof(sampler));
|
||||
}
|
||||
|
|
@ -61,12 +57,6 @@ namespace OpenTelemetry.Trace
|
|||
/// <inheritdoc/>
|
||||
public override ISpan CurrentSpan => SpanSdk.Current;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IBinaryFormat BinaryFormat { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ITextFormat TextFormat { get; }
|
||||
|
||||
public override IDisposable WithSpan(ISpan span, bool endSpanOnDispose)
|
||||
{
|
||||
if (span == null)
|
||||
|
|
|
|||
|
|
@ -156,9 +156,8 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests
|
|||
{
|
||||
services.AddSingleton<TracerFactory>(_ =>
|
||||
TracerFactory.Create(b => b
|
||||
.SetTextFormat(textFormat.Object)
|
||||
.AddProcessorPipeline(p => p.AddProcessor(n => spanProcessor.Object))
|
||||
.AddRequestCollector()));
|
||||
.AddRequestCollector(o => o.TextFormat = textFormat.Object)));
|
||||
})))
|
||||
using (var client = testFactory.CreateClient())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ namespace OpenTelemetry.Collector.Dependencies.Tests
|
|||
|
||||
var spanProcessor = new Mock<SpanProcessor>();
|
||||
var tracer = TracerFactory.Create(b => b
|
||||
.SetTextFormat(textFormat.Object)
|
||||
.AddProcessorPipeline(p => p.AddProcessor(_ => spanProcessor.Object)))
|
||||
.GetTracer(null);
|
||||
|
||||
|
|
@ -128,7 +127,7 @@ namespace OpenTelemetry.Collector.Dependencies.Tests
|
|||
parent.TraceStateString = "k1=v1,k2=v2";
|
||||
parent.ActivityTraceFlags = ActivityTraceFlags.Recorded;
|
||||
|
||||
using (new HttpClientCollector(tracer, new HttpClientCollectorOptions()))
|
||||
using (new HttpClientCollector(tracer, new HttpClientCollectorOptions {TextFormat = textFormat.Object}))
|
||||
using (var c = new HttpClient())
|
||||
{
|
||||
await c.SendAsync(request);
|
||||
|
|
|
|||
|
|
@ -31,14 +31,18 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
[Fact]
|
||||
public void CtorArgumentValidation()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => TracerShim.Create(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerShim(null, new TraceContextFormat(), new BinaryFormat()));
|
||||
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerShim(tracerMock.Object, null, new BinaryFormat()));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerShim(tracerMock.Object, new TraceContextFormat(), null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScopeManager_NotNull()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
// Internals of the ScopeManagerShim tested elsewhere
|
||||
Assert.NotNull(shim.ScopeManager as ScopeManagerShim);
|
||||
|
|
@ -48,7 +52,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
public void BuildSpan_NotNull()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
// Internals of the SpanBuilderShim tested elsewhere
|
||||
Assert.NotNull(shim.BuildSpan("foo") as SpanBuilderShim);
|
||||
|
|
@ -58,7 +62,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
public void Inject_ArgumentValidation()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
var spanContextShim = new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
var mockFormat = new Mock<IFormat<ITextMap>>();
|
||||
|
|
@ -74,7 +78,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
public void Inject_UnknownFormatIgnored()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
var spanContextShim = new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
|
||||
|
|
@ -90,7 +94,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
public void Extract_ArgumentValidation()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => shim.Extract(null, new Mock<ITextMap>().Object));
|
||||
Assert.Throws<ArgumentNullException>(() => shim.Extract(new Mock<IFormat<ITextMap>>().Object, null));
|
||||
|
|
@ -100,7 +104,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
public void Extract_UnknownFormatIgnored()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
var spanContextShim = new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
|
||||
|
|
@ -116,7 +120,7 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
public void Extract_InvalidTraceParent()
|
||||
{
|
||||
var tracerMock = new Mock<Trace.Tracer>();
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), new BinaryFormat());
|
||||
|
||||
var mockCarrier = new Mock<ITextMap>();
|
||||
|
||||
|
|
@ -146,9 +150,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
var spanContextShim = new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
|
||||
var format = new TraceContextFormat();
|
||||
tracerMock.Setup(x => x.TextFormat).Returns(format);
|
||||
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, format, new BinaryFormat());
|
||||
|
||||
// first inject
|
||||
shim.Inject(spanContextShim, BuiltinFormats.TextMap, carrier);
|
||||
|
|
@ -169,9 +172,8 @@ namespace OpenTelemetry.Shims.OpenTracing.Tests
|
|||
var spanContextShim = new SpanContextShim(Defaults.GetOpenTelemetrySpanContext());
|
||||
|
||||
var format = new BinaryFormat();
|
||||
tracerMock.Setup(x => x.BinaryFormat).Returns(format);
|
||||
|
||||
var shim = TracerShim.Create(tracerMock.Object);
|
||||
var shim = new TracerShim(tracerMock.Object, new TraceContextFormat(), format);
|
||||
|
||||
// first inject
|
||||
shim.Inject(spanContextShim, BuiltinFormats.Binary, carrier);
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
Assert.Throws<ArgumentNullException>(() => new TracerBuilder().SetSampler(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerBuilder().AddProcessorPipeline(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerBuilder().SetTracerOptions(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerBuilder().SetBinaryFormat(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerBuilder().SetTextFormat(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerBuilder().AddCollector<object>(null));
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +44,6 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
var builder = new TracerBuilder();
|
||||
Assert.Null(builder.Sampler);
|
||||
Assert.Null(builder.ProcessingPipelines);
|
||||
Assert.Null(builder.BinaryFormat);
|
||||
Assert.Null(builder.TextFormat);
|
||||
Assert.Null(builder.TracerConfigurationOptions);
|
||||
Assert.Null(builder.CollectorFactories);
|
||||
}
|
||||
|
|
@ -63,8 +59,6 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
var sampler = new ProbabilitySampler(0.1);
|
||||
var exporter = new TestExporter(_ => { });
|
||||
var options = new TracerConfiguration(1, 1, 1);
|
||||
var binaryFormat = new BinaryFormat();
|
||||
var textFormat = new TraceContextFormat();
|
||||
|
||||
builder
|
||||
.SetSampler(sampler)
|
||||
|
|
@ -77,8 +71,6 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
return new SimpleSpanProcessor(e);
|
||||
}))
|
||||
.SetTracerOptions(options)
|
||||
.SetBinaryFormat(binaryFormat)
|
||||
.SetTextFormat(textFormat)
|
||||
.AddCollector(t =>
|
||||
{
|
||||
Assert.NotNull(t);
|
||||
|
|
@ -95,8 +87,6 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
Assert.True(processorFactoryCalled);
|
||||
|
||||
Assert.Same(options, builder.TracerConfigurationOptions);
|
||||
Assert.Same(binaryFormat, builder.BinaryFormat);
|
||||
Assert.Same(textFormat, builder.TextFormat);
|
||||
Assert.Single(builder.CollectorFactories);
|
||||
|
||||
var collectorFactory = builder.CollectorFactories.Single();
|
||||
|
|
@ -104,8 +94,7 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
Assert.Equal("semver:" + typeof(TestCollector).Assembly.GetName().Version, collectorFactory.Version);
|
||||
|
||||
Assert.NotNull(collectorFactory.Factory);
|
||||
collectorFactory.Factory(new TracerSdk(new SimpleSpanProcessor(exporter), new AlwaysSampleSampler(), options, binaryFormat, textFormat,
|
||||
Resource.Empty));
|
||||
collectorFactory.Factory(new TracerSdk(new SimpleSpanProcessor(exporter), new AlwaysSampleSampler(), options, Resource.Empty));
|
||||
|
||||
Assert.True(collectorFactoryCalled);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,9 +44,6 @@ namespace OpenTelemetry.Trace.Test
|
|||
Assert.NotNull(tracer);
|
||||
Assert.IsType<TracerSdk>(tracer);
|
||||
|
||||
Assert.IsType<BinaryFormat>(tracer.BinaryFormat);
|
||||
Assert.IsType<TraceContextFormat>(tracer.TextFormat);
|
||||
|
||||
var span = tracer.StartSpan("foo");
|
||||
Assert.NotNull(span);
|
||||
Assert.IsType<SpanSdk>(span);
|
||||
|
|
|
|||
|
|
@ -253,15 +253,6 @@ namespace OpenTelemetry.Tests.Impl.Trace
|
|||
Assert.Equal(linkContext, span.Links.Single().Context);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProxyTracer_Formats()
|
||||
{
|
||||
Assert.NotNull(new ProxyTracer().TextFormat);
|
||||
Assert.NotNull(new ProxyTracer().BinaryFormat);
|
||||
Assert.IsAssignableFrom<ITextFormat>(new ProxyTracer().TextFormat);
|
||||
Assert.IsAssignableFrom<IBinaryFormat>(new ProxyTracer().BinaryFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,14 +52,9 @@ namespace OpenTelemetry.Trace.Test
|
|||
public void BadConstructorArgumentsThrow()
|
||||
{
|
||||
var noopProc = new SimpleSpanProcessor(new TestExporter(null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(null, new AlwaysSampleSampler(), new TracerConfiguration(), new BinaryFormat(), new TraceContextFormat(), Resource.Empty));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(noopProc, new AlwaysSampleSampler(), null, new BinaryFormat(), new TraceContextFormat(), Resource.Empty));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(noopProc, new AlwaysSampleSampler(), new TracerConfiguration(), null, new TraceContextFormat(), Resource.Empty));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(noopProc, new AlwaysSampleSampler(), new TracerConfiguration(), new BinaryFormat(), null, Resource.Empty));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(noopProc, new AlwaysSampleSampler(), new TracerConfiguration(), new BinaryFormat(), new TraceContextFormat(), null));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(null, new AlwaysSampleSampler(), new TracerConfiguration(), Resource.Empty));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(noopProc, new AlwaysSampleSampler(), null, Resource.Empty));
|
||||
Assert.Throws<ArgumentNullException>(() => new TracerSdk(noopProc, new AlwaysSampleSampler(), new TracerConfiguration(), null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -189,18 +184,6 @@ namespace OpenTelemetry.Trace.Test
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTextFormat()
|
||||
{
|
||||
Assert.NotNull(this.tracerSdk.TextFormat);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBinaryFormat()
|
||||
{
|
||||
Assert.NotNull(this.tracerSdk.BinaryFormat);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DroppingAndAddingAttributes()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue