From 6bf0e18d60c087e9d3de0af1d65588596797adef Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Mon, 7 Oct 2019 12:48:51 -0700 Subject: [PATCH] Rename TraceConfig to TracerConfiguration and remove Default (#258) * TraceConfig to TracerConfiguration and remove Default * Add TracerConfiguration file and fix namespace --- .../Implementation/SpanExtensions.cs | 3 - .../TracerConfiguration.cs} | 21 ++-- src/OpenTelemetry/Trace/Span.cs | 18 +-- src/OpenTelemetry/Trace/SpanBuilder.cs | 16 +-- src/OpenTelemetry/Trace/Tracer.cs | 19 ++- src/OpenTelemetry/Trace/TracerFactory.cs | 12 +- src/OpenTelemetry/Trace/Tracing.cs | 8 +- .../BasicTests.cs | 12 +- ...stsCollectionsIsAccordingToTheSpecTests.cs | 2 +- .../BasicTests.cs | 5 +- .../HttpClientTests.cs | 2 +- .../RedisProfilerEntryToSpanConverterTests.cs | 4 +- .../StackExchangeRedisCallsCollectorTests.cs | 4 +- .../ApplicationInsightsTraceExporterTests.cs | 5 +- .../Impl/Trace/Config/TraceParamsTest.cs | 21 ++-- .../Impl/Trace/CurrentSpanUtilsTest.cs | 20 +-- .../Export/BatchingSpanProcessorTests.cs | 8 +- .../Trace/Export/SimpleSpanProcessorTests.cs | 10 +- .../Impl/Trace/SpanBuilderTest.cs | 118 +++++++++--------- .../Impl/Trace/SpanTest.cs | 37 +++--- .../Impl/Trace/TracerTest.cs | 30 ++--- .../Impl/Trace/TracingTest.cs | 8 +- test/TestApp.AspNetCore.2.0/Startup.cs | 4 +- 23 files changed, 189 insertions(+), 198 deletions(-) rename src/OpenTelemetry/Trace/{Config/TraceConfig.cs => Configuration/TracerConfiguration.cs} (80%) diff --git a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/SpanExtensions.cs b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/SpanExtensions.cs index ca539b42f0a..9f9bf8124bd 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/SpanExtensions.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/SpanExtensions.cs @@ -20,7 +20,6 @@ namespace OpenTelemetry.Exporter.Stackdriver.Implementation using Google.Cloud.Trace.V2; using Google.Protobuf.WellKnownTypes; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; internal static class SpanExtensions { @@ -90,8 +89,6 @@ public static Google.Cloud.Trace.V2.Span.Types.Link ToLink(this Link link) { ret.Attributes = new Google.Cloud.Trace.V2.Span.Types.Attributes { - DroppedAttributesCount = TraceConfig.Default.MaxNumberOfAttributes - link.Attributes.Count, - AttributeMap = { link.Attributes.ToDictionary( diff --git a/src/OpenTelemetry/Trace/Config/TraceConfig.cs b/src/OpenTelemetry/Trace/Configuration/TracerConfiguration.cs similarity index 80% rename from src/OpenTelemetry/Trace/Config/TraceConfig.cs rename to src/OpenTelemetry/Trace/Configuration/TracerConfiguration.cs index a007b9f71a4..2cd2f246a34 100644 --- a/src/OpenTelemetry/Trace/Config/TraceConfig.cs +++ b/src/OpenTelemetry/Trace/Configuration/TracerConfiguration.cs @@ -1,4 +1,4 @@ -// +// // Copyright 2018, OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +14,7 @@ // limitations under the License. // -namespace OpenTelemetry.Trace.Config +namespace OpenTelemetry.Trace.Configuration { using System; using OpenTelemetry.Trace.Sampler; @@ -22,24 +22,23 @@ namespace OpenTelemetry.Trace.Config /// /// Trace configuration that can be updates in runtime. /// - public sealed class TraceConfig + public sealed class TracerConfiguration { - /// - /// Default trace parameters. - /// - public static readonly TraceConfig Default = - new TraceConfig(Samplers.AlwaysSample, DefaultSpanMaxNumAttributes, DefaultSpanMaxNumEvents, DefaultSpanMaxNumLinks); - private const int DefaultSpanMaxNumAttributes = 32; private const int DefaultSpanMaxNumEvents = 128; private const int DefaultSpanMaxNumLinks = 32; - public TraceConfig(ISampler sampler) + public TracerConfiguration() + : this(Samplers.AlwaysSample, DefaultSpanMaxNumAttributes, DefaultSpanMaxNumEvents, DefaultSpanMaxNumLinks) + { + } + + public TracerConfiguration(ISampler sampler) : this(sampler, DefaultSpanMaxNumAttributes, DefaultSpanMaxNumEvents, DefaultSpanMaxNumLinks) { } - public TraceConfig(ISampler sampler, int maxNumberOfAttributes, int maxNumberOfEvents, int maxNumberOfLinks) + public TracerConfiguration(ISampler sampler, int maxNumberOfAttributes, int maxNumberOfEvents, int maxNumberOfLinks) { if (maxNumberOfAttributes <= 0) { diff --git a/src/OpenTelemetry/Trace/Span.cs b/src/OpenTelemetry/Trace/Span.cs index 06b87503631..699a44be0fb 100644 --- a/src/OpenTelemetry/Trace/Span.cs +++ b/src/OpenTelemetry/Trace/Span.cs @@ -21,7 +21,7 @@ namespace OpenTelemetry.Trace using System.Diagnostics; using System.Linq; using OpenTelemetry.Resources; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Internal; using OpenTelemetry.Utils; @@ -31,7 +31,7 @@ namespace OpenTelemetry.Trace /// public sealed class Span : ISpan { - private readonly TraceConfig traceConfig; + private readonly TracerConfiguration tracerConfiguration; private readonly SpanProcessor spanProcessor; private readonly Lazy spanContext; private readonly DateTimeOffset startTimestamp; @@ -46,7 +46,7 @@ internal Span( Activity activity, IEnumerable> tracestate, SpanKind spanKind, - TraceConfig traceConfig, + TracerConfiguration tracerConfiguration, SpanProcessor spanProcessor, DateTimeOffset startTimestamp, bool ownsActivity, @@ -59,7 +59,7 @@ internal Span( this.Activity.ActivityTraceFlags, tracestate)); this.Name = this.Activity.OperationName; - this.traceConfig = traceConfig; + this.tracerConfiguration = tracerConfiguration; this.spanProcessor = spanProcessor; this.Kind = spanKind; this.OwnsActivity = ownsActivity; @@ -185,7 +185,7 @@ public void SetAttribute(KeyValuePair keyValuePair) if (this.attributes == null) { - this.attributes = new EvictingQueue>(this.traceConfig.MaxNumberOfAttributes); + this.attributes = new EvictingQueue>(this.tracerConfiguration.MaxNumberOfAttributes); } this.attributes.AddEvent(new KeyValuePair(keyValuePair.Key, keyValuePair.Value)); @@ -216,7 +216,7 @@ public void AddEvent(string name) if (this.events == null) { this.events = - new EvictingQueue(this.traceConfig.MaxNumberOfEvents); + new EvictingQueue(this.tracerConfiguration.MaxNumberOfEvents); } this.events.AddEvent(new Event(name, PreciseTimestamp.GetUtcNow())); @@ -252,7 +252,7 @@ public void AddEvent(string name, IDictionary eventAttributes) if (this.events == null) { this.events = - new EvictingQueue(this.traceConfig.MaxNumberOfEvents); + new EvictingQueue(this.tracerConfiguration.MaxNumberOfEvents); } this.events.AddEvent(new Event(name, PreciseTimestamp.GetUtcNow(), eventAttributes)); @@ -283,7 +283,7 @@ public void AddEvent(Event addEvent) if (this.events == null) { this.events = - new EvictingQueue(this.traceConfig.MaxNumberOfEvents); + new EvictingQueue(this.tracerConfiguration.MaxNumberOfEvents); } this.events.AddEvent(addEvent); @@ -313,7 +313,7 @@ public void AddLink(Link link) if (this.links == null) { - this.links = new EvictingQueue(this.traceConfig.MaxNumberOfLinks); + this.links = new EvictingQueue(this.tracerConfiguration.MaxNumberOfLinks); } this.links.AddEvent(link); diff --git a/src/OpenTelemetry/Trace/SpanBuilder.cs b/src/OpenTelemetry/Trace/SpanBuilder.cs index 7661bcd4c61..27e5685e9af 100644 --- a/src/OpenTelemetry/Trace/SpanBuilder.cs +++ b/src/OpenTelemetry/Trace/SpanBuilder.cs @@ -22,7 +22,7 @@ namespace OpenTelemetry.Trace using System.Linq; using OpenTelemetry.Context.Propagation; using OpenTelemetry.Resources; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Internal; @@ -30,7 +30,7 @@ namespace OpenTelemetry.Trace public class SpanBuilder : ISpanBuilder { private readonly SpanProcessor spanProcessor; - private readonly TraceConfig traceConfig; + private readonly TracerConfiguration tracerConfiguration; private readonly string name; private SpanKind kind; @@ -45,11 +45,11 @@ public class SpanBuilder : ISpanBuilder private DateTimeOffset startTimestamp; private Resource libraryResource; - internal SpanBuilder(string name, SpanProcessor spanProcessor, TraceConfig traceConfig, Resource libraryResource) + internal SpanBuilder(string name, SpanProcessor spanProcessor, TracerConfiguration tracerConfiguration, Resource libraryResource) { this.name = name ?? throw new ArgumentNullException(nameof(name)); this.spanProcessor = spanProcessor ?? throw new ArgumentNullException(nameof(spanProcessor)); - this.traceConfig = traceConfig ?? throw new ArgumentNullException(nameof(traceConfig)); + this.tracerConfiguration = tracerConfiguration ?? throw new ArgumentNullException(nameof(tracerConfiguration)); this.libraryResource = libraryResource ?? throw new ArgumentNullException(nameof(libraryResource)); } @@ -217,7 +217,7 @@ public ISpan StartSpan() this.links, activityForSpan.TraceId, activityForSpan.SpanId, - this.traceConfig); + this.tracerConfiguration); if (sampledIn || this.recordEvents) { @@ -251,7 +251,7 @@ public ISpan StartSpan() activityForSpan, childTracestate, this.kind, - this.traceConfig, + this.tracerConfiguration, this.spanProcessor, this.startTimestamp, ownsActivity: this.contextSource != ContextSource.Activity, @@ -300,7 +300,7 @@ private static bool MakeSamplingDecision( List parentLinks, ActivityTraceId traceId, ActivitySpanId spanId, - TraceConfig traceConfig) + TracerConfiguration tracerConfiguration) { // If users set a specific sampler in the SpanBuilder, use it. if (sampler != null) @@ -312,7 +312,7 @@ private static bool MakeSamplingDecision( // parent). if (parent == null || !parent.IsValid) { - return traceConfig + return tracerConfiguration .Sampler .ShouldSample(parent, traceId, spanId, name, parentLinks).IsSampled; } diff --git a/src/OpenTelemetry/Trace/Tracer.cs b/src/OpenTelemetry/Trace/Tracer.cs index 1c4c6c38fcf..351d96cafed 100644 --- a/src/OpenTelemetry/Trace/Tracer.cs +++ b/src/OpenTelemetry/Trace/Tracer.cs @@ -18,10 +18,9 @@ namespace OpenTelemetry.Trace { using System; using System.Diagnostics; - using OpenTelemetry.Context; using OpenTelemetry.Context.Propagation; using OpenTelemetry.Resources; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Internal; @@ -40,10 +39,10 @@ static Tracer() /// Creates an instance of . /// /// Span processor. - /// Trace configuration. + /// Trace configuration. /// Resource describing the instrumentation library. - public Tracer(SpanProcessor spanProcessor, TraceConfig traceConfig, Resource libraryResource) - : this(spanProcessor, traceConfig, new BinaryFormat(), new TraceContextFormat(), libraryResource) + public Tracer(SpanProcessor spanProcessor, TracerConfiguration tracerConfiguration, Resource libraryResource) + : this(spanProcessor, tracerConfiguration, new BinaryFormat(), new TraceContextFormat(), libraryResource) { } @@ -51,14 +50,14 @@ public Tracer(SpanProcessor spanProcessor, TraceConfig traceConfig, Resource lib /// Creates an instance of . /// /// Span processor. - /// Trace configuration. + /// Trace configuration. /// Binary format context propagator. /// Text format context propagator. /// Resource describing the instrumentation library. - internal Tracer(SpanProcessor spanProcessor, TraceConfig traceConfig, IBinaryFormat binaryFormat, ITextFormat textFormat, Resource libraryResource) + internal Tracer(SpanProcessor spanProcessor, TracerConfiguration tracerConfiguration, IBinaryFormat binaryFormat, ITextFormat textFormat, Resource libraryResource) { this.spanProcessor = spanProcessor ?? throw new ArgumentNullException(nameof(spanProcessor)); - this.ActiveTraceConfig = traceConfig ?? throw new ArgumentNullException(nameof(traceConfig)); + this.ActiveTracerConfiguration = 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)); @@ -75,12 +74,12 @@ internal Tracer(SpanProcessor spanProcessor, TraceConfig traceConfig, IBinaryFor /// public ITextFormat TextFormat { get; } - public TraceConfig ActiveTraceConfig { get; set; } + public TracerConfiguration ActiveTracerConfiguration { get; set; } /// public ISpanBuilder SpanBuilder(string spanName) { - return new SpanBuilder(spanName, this.spanProcessor, this.ActiveTraceConfig, this.LibraryResource); + return new SpanBuilder(spanName, this.spanProcessor, this.ActiveTracerConfiguration, this.LibraryResource); } public IDisposable WithSpan(ISpan span) diff --git a/src/OpenTelemetry/Trace/TracerFactory.cs b/src/OpenTelemetry/Trace/TracerFactory.cs index 8be7666807e..7e5433c4465 100644 --- a/src/OpenTelemetry/Trace/TracerFactory.cs +++ b/src/OpenTelemetry/Trace/TracerFactory.cs @@ -19,7 +19,7 @@ namespace OpenTelemetry.Trace using System.Collections.Generic; using OpenTelemetry.Context.Propagation; using OpenTelemetry.Resources; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; /// @@ -27,19 +27,19 @@ public sealed class TracerFactory : ITracerFactory { private readonly object lck = new object(); private readonly SpanProcessor spanProcessor; - private readonly TraceConfig traceConfig; + private readonly TracerConfiguration tracerConfiguration; private readonly ITextFormat textFormat; private readonly IBinaryFormat binaryFormat; private readonly Tracer defaultTracer; private readonly Dictionary tracerRegistry = new Dictionary(); - public TracerFactory(SpanProcessor spanProcessor = null, TraceConfig traceConfig = null, ITextFormat textFormat = null, IBinaryFormat binaryFormat = null) + public TracerFactory(SpanProcessor spanProcessor = null, TracerConfiguration tracerConfiguration = null, ITextFormat textFormat = null, IBinaryFormat binaryFormat = null) { this.spanProcessor = spanProcessor ?? Tracing.SpanProcessor; - this.traceConfig = traceConfig ?? Tracing.TraceConfig; + this.tracerConfiguration = tracerConfiguration ?? Tracing.TracerConfiguration; this.textFormat = textFormat ?? new TraceContextFormat(); this.binaryFormat = binaryFormat ?? new BinaryFormat(); - this.defaultTracer = new Tracer(this.spanProcessor, this.traceConfig, this.binaryFormat, this.textFormat, Resource.Empty); + this.defaultTracer = new Tracer(this.spanProcessor, this.tracerConfiguration, this.binaryFormat, this.textFormat, Resource.Empty); } /// @@ -56,7 +56,7 @@ public override ITracer GetTracer(string name, string version = null) if (!this.tracerRegistry.TryGetValue(key, out var tracer)) { var labels = CreateLibraryResourceLabels(name, version); - tracer = new Tracer(this.spanProcessor, this.traceConfig, this.binaryFormat, this.textFormat, new Resource(labels)); + tracer = new Tracer(this.spanProcessor, this.tracerConfiguration, this.binaryFormat, this.textFormat, new Resource(labels)); this.tracerRegistry.Add(key, tracer); } diff --git a/src/OpenTelemetry/Trace/Tracing.cs b/src/OpenTelemetry/Trace/Tracing.cs index 9e35dff90a3..c174a580167 100644 --- a/src/OpenTelemetry/Trace/Tracing.cs +++ b/src/OpenTelemetry/Trace/Tracing.cs @@ -16,7 +16,7 @@ namespace OpenTelemetry.Trace { - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; /// @@ -28,9 +28,9 @@ public static class Tracing static Tracing() { - TraceConfig = TraceConfig.Default; + TracerConfiguration = new TracerConfiguration(); SpanProcessor = new BatchingSpanProcessor(new NoopSpanExporter()); - tracerFactory = new TracerFactory(SpanProcessor, TraceConfig); + tracerFactory = new TracerFactory(SpanProcessor, TracerConfiguration); } /// @@ -46,6 +46,6 @@ static Tracing() /// /// Gets the trace config. /// - public static TraceConfig TraceConfig { get; } + public static TracerConfiguration TracerConfiguration { get; } } } diff --git a/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs index 83d9ec94942..4bfe07a802d 100644 --- a/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs @@ -24,7 +24,7 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using Moq; using Microsoft.AspNetCore.TestHost; @@ -48,8 +48,8 @@ public BasicTests(WebApplicationFactory factory) [Fact] public async Task SuccessfulTemplateControllerCallGeneratesASpan() { - var panProcessor = new Mock(new NoopSpanExporter()); - var tracerFactory = new TracerFactory(panProcessor.Object); + var spanProcessor = new Mock(new NoopSpanExporter()); + var tracerFactory = new TracerFactory(spanProcessor.Object); void ConfigureTestServices(IServiceCollection services) => services.AddSingleton(tracerFactory); @@ -69,7 +69,7 @@ void ConfigureTestServices(IServiceCollection services) => for (var i = 0; i < 10; i++) { - if (panProcessor.Invocations.Count == 2) + if (spanProcessor.Invocations.Count == 2) { break; } @@ -82,8 +82,8 @@ void ConfigureTestServices(IServiceCollection services) => } - Assert.Equal(2, panProcessor.Invocations.Count); // begin and end was called - var span = ((Span)panProcessor.Invocations[1].Arguments[0]); + Assert.Equal(2, spanProcessor.Invocations.Count); // begin and end was called + var span = ((Span)spanProcessor.Invocations[1].Arguments[0]); Assert.Equal(SpanKind.Server, span.Kind); Assert.Equal("/api/values", span.Attributes.GetValue("http.path")); diff --git a/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs b/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs index f4fb233d227..4886daa797d 100644 --- a/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs +++ b/test/OpenTelemetry.Collector.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs @@ -24,7 +24,7 @@ namespace OpenTelemetry.Collector.AspNetCore.Tests using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using Moq; using Microsoft.AspNetCore.TestHost; diff --git a/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs b/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs index 04fc3dc2dae..4913359204c 100644 --- a/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs @@ -14,18 +14,15 @@ // limitations under the License. // -using System.Linq; -using OpenTelemetry.Resources; - namespace OpenTelemetry.Collector.Dependencies.Tests { using Moq; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Sampler; using System; using System.Diagnostics; + using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Xunit; diff --git a/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs b/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs index 4a6538a0961..2e5ffffa255 100644 --- a/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs +++ b/test/OpenTelemetry.Collector.Dependencies.Tests/HttpClientTests.cs @@ -21,7 +21,7 @@ namespace OpenTelemetry.Collector.Dependencies.Tests using Moq; using Newtonsoft.Json; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Sampler; using System; diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs index 824f341b163..82e2cf49af4 100644 --- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs +++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs @@ -23,7 +23,7 @@ namespace OpenTelemetry.Collector.StackExchangeRedis.Implementation using Moq; using OpenTelemetry.Collector.StackExchangeRedis.Tests; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using StackExchange.Redis.Profiling; using Xunit; @@ -34,7 +34,7 @@ public class RedisProfilerEntryToSpanConverterTests public RedisProfilerEntryToSpanConverterTests() { - tracer = new Tracer(new SimpleSpanProcessor(new NoopSpanExporter()), TraceConfig.Default, Resource.Empty); + tracer = new Tracer(new SimpleSpanProcessor(new NoopSpanExporter()), new TracerConfiguration(), Resource.Empty); } [Fact] diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs index efca37e49d3..c05eda87cd7 100644 --- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs +++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/StackExchangeRedisCallsCollectorTests.cs @@ -20,7 +20,7 @@ namespace OpenTelemetry.Collector.StackExchangeRedis { using Moq; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using StackExchange.Redis.Profiling; using System.Threading.Tasks; @@ -32,7 +32,7 @@ public class StackExchangeRedisCallsCollectorTests public async void ProfilerSessionUsesTheSameDefault() { var spanProcessor = new Mock(new NoopSpanExporter()); - var tracer = new Tracer(spanProcessor.Object, TraceConfig.Default, Resource.Empty); + var tracer = new Tracer(spanProcessor.Object, new TracerConfiguration(), Resource.Empty); using (var collector = new StackExchangeRedisCallsCollector(tracer)) { diff --git a/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/ApplicationInsightsTraceExporterTests.cs b/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/ApplicationInsightsTraceExporterTests.cs index 3a8235a9c3e..b553d9826f0 100644 --- a/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/ApplicationInsightsTraceExporterTests.cs +++ b/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/ApplicationInsightsTraceExporterTests.cs @@ -14,10 +14,6 @@ // limitations under the License. // -using System.Threading; -using OpenTelemetry.Trace.Config; -using OpenTelemetry.Trace.Export; - namespace OpenTelemetry.Exporter.ApplicationInsights.Tests { using Microsoft.ApplicationInsights.Channel; @@ -31,6 +27,7 @@ namespace OpenTelemetry.Exporter.ApplicationInsights.Tests using System.Collections.Generic; using System.Diagnostics; using System.Linq; + using System.Threading; using Xunit; public class ApplicationInsightsTraceExporterTests diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs index f07a27c4de5..1e2ec3535b0 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs @@ -17,7 +17,7 @@ namespace OpenTelemetry.Trace.Config.Test { using System; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Sampler; using Xunit; @@ -26,41 +26,42 @@ public class TraceConfigTest [Fact] public void DefaultTraceConfig() { - Assert.Equal(Samplers.AlwaysSample, TraceConfig.Default.Sampler); - Assert.Equal(32, TraceConfig.Default.MaxNumberOfAttributes); - Assert.Equal(128, TraceConfig.Default.MaxNumberOfEvents); - Assert.Equal(32, TraceConfig.Default.MaxNumberOfLinks); + var config = new TracerConfiguration(); + Assert.Equal(Samplers.AlwaysSample, config.Sampler); + Assert.Equal(32, config.MaxNumberOfAttributes); + Assert.Equal(128, config.MaxNumberOfEvents); + Assert.Equal(32, config.MaxNumberOfLinks); } [Fact] public void UpdateTraceParams_NullSampler() { - Assert.Throws(() => new TraceConfig(null)); + Assert.Throws(() => new TracerConfiguration(null)); } [Fact] public void UpdateTraceParams_NonPositiveMaxNumberOfAttributes() { - Assert.Throws(() => new TraceConfig(Samplers.AlwaysSample, 0 ,1, 1)); + Assert.Throws(() => new TracerConfiguration(Samplers.AlwaysSample, 0 ,1, 1)); } [Fact] public void UpdateTraceParams_NonPositiveMaxNumberOfEvents() { - Assert.Throws(() => new TraceConfig(Samplers.AlwaysSample, 1, 0, 1)); + Assert.Throws(() => new TracerConfiguration(Samplers.AlwaysSample, 1, 0, 1)); } [Fact] public void updateTraceParams_NonPositiveMaxNumberOfLinks() { - Assert.Throws(() => new TraceConfig(Samplers.AlwaysSample, 1, 1, 0)); + Assert.Throws(() => new TracerConfiguration(Samplers.AlwaysSample, 1, 1, 0)); } [Fact] public void UpdateTraceParams_All() { - var traceParams = new TraceConfig(Samplers.NeverSample, 8, 9, 11); + var traceParams = new TracerConfiguration(Samplers.NeverSample, 8, 9, 11); Assert.Equal(Samplers.NeverSample, traceParams.Sampler); Assert.Equal(8, traceParams.MaxNumberOfAttributes); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs index eea1e07aba7..2463733e239 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs @@ -22,7 +22,7 @@ namespace OpenTelemetry.Trace.Test using System; using System.Diagnostics; using Moq; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using Xunit; @@ -66,7 +66,7 @@ public void WithSpan_CloseDetaches(bool stopSpan, bool recordEvents) activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -101,7 +101,7 @@ public void WithSpan_NotOwningActivity(bool stopSpan, bool recordEvents) activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, false, @@ -135,7 +135,7 @@ public void WithSpan_NoopOnBrokenScope(bool stopSpan, bool recordEvents) parentActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -148,7 +148,7 @@ public void WithSpan_NoopOnBrokenScope(bool stopSpan, bool recordEvents) childActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -183,7 +183,7 @@ public void WithSpan_RestoresParentScope(bool stopSpan, bool recordEvents) parentActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -196,7 +196,7 @@ public void WithSpan_RestoresParentScope(bool stopSpan, bool recordEvents) childActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -223,7 +223,7 @@ public void WithSpan_SameActivityCreateScopeTwice() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -248,7 +248,7 @@ public void WithSpan_NullActivity() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, @@ -283,7 +283,7 @@ public void WithSpan_WrongActivity(bool stopSpan, bool recordEvents) activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, true, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/BatchingSpanProcessorTests.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/BatchingSpanProcessorTests.cs index 01983f085d9..b812bb81fab 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/BatchingSpanProcessorTests.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/BatchingSpanProcessorTests.cs @@ -27,7 +27,7 @@ namespace OpenTelemetry.Trace.Export.Test using OpenTelemetry.Testing.Export; using OpenTelemetry.Utils; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using Xunit; @@ -56,7 +56,7 @@ private Span CreateSampledEndedSpan(string spanName) sampledActivity, Enumerable.Empty>(), SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), default, @@ -75,7 +75,7 @@ private Span CreateNotSampledEndedSpan(string spanName) notSampledActivity, Enumerable.Empty>(), SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), false, @@ -246,7 +246,7 @@ public void ProcessorDoesNotBlockOnExporter() sampledActivity, Enumerable.Empty>(), SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), default, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/SimpleSpanProcessorTests.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/SimpleSpanProcessorTests.cs index 6d6a7fc44d0..7e1f00143d9 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/SimpleSpanProcessorTests.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/SimpleSpanProcessorTests.cs @@ -23,7 +23,7 @@ namespace OpenTelemetry.Trace.Export.Test using System.Threading; using System.Threading.Tasks; using OpenTelemetry.Testing.Export; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Utils; using Xunit; @@ -52,7 +52,7 @@ private Span CreateSampledEndedSpan(string spanName) sampledActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), default, @@ -71,7 +71,7 @@ private Span CreateNotSampledEndedSpan(string spanName) notSampledActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), false, @@ -101,7 +101,7 @@ public void ThrowsInExporter() sampledActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), default, @@ -127,7 +127,7 @@ public void ProcessorDoesNotBlockOnExporter() sampledActivity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), default, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs index 8a0170486df..f37965cf8b7 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs @@ -20,10 +20,9 @@ namespace OpenTelemetry.Trace.Test using System.Diagnostics; using System.Collections.Generic; using System.Linq; - using Moq; using OpenTelemetry.Abstractions.Utils; using OpenTelemetry.Context.Propagation; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Sampler; using OpenTelemetry.Resources; @@ -33,20 +32,20 @@ public class SpanBuilderTest : IDisposable { private static readonly string SpanName = "MySpanName"; - private readonly TraceConfig alwaysSampleTraceConfig = new TraceConfig(Samplers.AlwaysSample); + private readonly TracerConfiguration alwaysSampleTracerConfiguration = new TracerConfiguration(Samplers.AlwaysSample); private readonly SpanProcessor spanProcessor = new SimpleSpanProcessor(new NoopSpanExporter()); private readonly ITracer tracer; public SpanBuilderTest() { - tracer = new Tracer(spanProcessor, alwaysSampleTraceConfig, Resource.Empty); + tracer = new Tracer(spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty); } [Fact] public void StartSpanNullParent() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetNoParent() .StartSpan(); @@ -73,7 +72,7 @@ public void StartSpanLastParentWins1() ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - var span = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetNoParent() .SetParent(spanContext) .StartSpan(); @@ -92,7 +91,7 @@ public void StartSpanLastParentWins2() ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - var span = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetParent(spanContext) .SetNoParent() .StartSpan(); @@ -110,10 +109,10 @@ public void StartSpanLastParentWins3() ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - var rootSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .StartSpan(); - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetParent(spanContext) .SetParent(rootSpan) .StartSpan(); @@ -131,11 +130,10 @@ public void StartSpanLastParentWins4() ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - - var rootSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .StartSpan(); - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetParent(rootSpan) .SetParent(spanContext) .StartSpan(); @@ -157,7 +155,7 @@ public void StartSpanLastParentWins5() .SetIdFormat(ActivityIdFormat.W3C) .Start(); - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetParent(spanContext) .SetParent(activity) .StartSpan(); @@ -179,7 +177,7 @@ public void StartSpanLastParentWins6() .SetIdFormat(ActivityIdFormat.W3C) .Start(); - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetParent(spanContext) .SetCreateChild(false) .StartSpan(); @@ -201,7 +199,7 @@ public void StartSpanLastParentWins7() .SetIdFormat(ActivityIdFormat.W3C) .Start(); - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetCreateChild(false) .SetParent(spanContext) .StartSpan(); @@ -214,7 +212,7 @@ public void StartSpanLastParentWins7() [Fact] public void StartSpanNullParentWithRecordEvents() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetRecordEvents(true) @@ -230,7 +228,7 @@ public void StartSpanNullParentWithRecordEvents() public void StartSpanWithStartTimestamp() { var timestamp = DateTime.UtcNow.AddSeconds(-100); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.AlwaysSample) .SetStartTimestamp(timestamp) @@ -243,7 +241,7 @@ public void StartSpanWithStartTimestamp() public void StartSpanWithImplicitTimestamp() { var timestamp = PreciseTimestamp.GetUtcNow(); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.AlwaysSample) .StartSpan(); @@ -254,7 +252,7 @@ public void StartSpanWithImplicitTimestamp() [Fact] public void StartSpanNullParentNoRecordOptions() { - var span = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetNoParent() @@ -267,7 +265,7 @@ public void StartSpanNullParentNoRecordOptions() [Fact] public void StartChildSpan() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetNoParent() .StartSpan(); @@ -276,7 +274,7 @@ public void StartChildSpan() Assert.True(rootSpan.IsRecordingEvents); Assert.True((rootSpan.Context.TraceOptions & ActivityTraceFlags.Recorded) != 0); - var childSpan = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(rootSpan) .StartSpan(); @@ -294,7 +292,7 @@ public void StartSpanInScopeOfCurrentActivity() .Start(); parentActivity.TraceStateString = "k1=v1,k2=v2"; - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .StartSpan(); @@ -317,7 +315,7 @@ public void StartSpanInScopeOfCurrentActivityRecorded() .Start(); parentActivity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .StartSpan(); @@ -334,7 +332,7 @@ public void StartSpanInScopeOfCurrentActivityNoParent() var parentActivity = new Activity(SpanName).Start(); parentActivity.TraceStateString = "k1=v1,k2=v2"; - var childSpan = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetNoParent() .StartSpan(); @@ -360,7 +358,7 @@ public void StartSpanFromExplicitActivity() parentActivity.TraceStateString = "k1=v1,k2=v2"; parentActivity.Stop(); - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(parentActivity) .StartSpan(); @@ -387,7 +385,7 @@ public void StartSpanFromExplicitRecordedActivity() parentActivity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; parentActivity.Stop(); - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(parentActivity) .StartSpan(); @@ -406,7 +404,7 @@ public void StartSpanFromCurrentActivity() .Start(); activity.TraceStateString = "k1=v1,k2=v2"; - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetCreateChild(false) .StartSpan(); @@ -431,7 +429,7 @@ public void StartSpanFromCurrentRecordedActivity() .Start(); activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; - var span = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetCreateChild(false) .StartSpan(); @@ -447,7 +445,7 @@ public void StartSpanFromCurrentRecordedActivity() [Fact] public void StartSpan_ExplicitNoParent() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetNoParent() .StartSpan(); @@ -468,7 +466,7 @@ public void StartSpan_ExplicitNoParent() [Fact] public void StartSpan_NoParent() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .StartSpan(); @@ -481,7 +479,7 @@ public void StartSpan_NoParent() [Fact] public void StartSpan_BlankSpanParent() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(BlankSpan.Instance) .StartSpan(); @@ -495,7 +493,7 @@ public void StartSpan_BlankSpanParent() [Fact] public void StartSpan_BlankSpanContextParent() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(SpanContext.Blank) .StartSpan(); @@ -511,7 +509,7 @@ public void StartSpan_BlankSpanContextParent() [Fact] public void StartSpan_CurrentSpanParent() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetParent( new SpanContext( ActivityTraceId.CreateRandom(), @@ -521,7 +519,7 @@ public void StartSpan_CurrentSpanParent() .StartSpan(); using (tracer.WithSpan(rootSpan)) { - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .StartSpan(); Assert.True(childSpan.Context.IsValid); @@ -534,11 +532,11 @@ public void StartSpan_CurrentSpanParent() [Fact] public void StartSpan_NoParentInScopeOfCurrentSpan() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .StartSpan(); using (tracer.WithSpan(rootSpan)) { - var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = (Span)new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetNoParent() .StartSpan(); @@ -551,7 +549,7 @@ public void StartSpan_NoParentInScopeOfCurrentSpan() [Fact] public void StartSpanInvalidParent() { - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(SpanContext.Blank) .StartSpan(); @@ -572,7 +570,7 @@ public void StartRemoteSpan() ActivityTraceFlags.None, new List> { new KeyValuePair("k1", "v1") }); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(spanContext) .SetRecordEvents(true) @@ -595,7 +593,7 @@ public void StartSpan_WithLink() ActivitySpanId.CreateRandom(), ActivityTraceFlags.None)); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .AddLink(link) .StartSpan(); @@ -617,7 +615,7 @@ public void StartSpan_WithLinkFromActivity() var contextLink = new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .AddLink(contextLink) .StartSpan(); @@ -644,7 +642,7 @@ public void StartSpan_WithLinkFromSpanContextAndAttributes() ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .AddLink(linkContext, new Dictionary { ["k"] = "v", }) .StartSpan(); @@ -671,7 +669,7 @@ public void StartSpan_WithLinkFromSpanContext() ActivitySpanId.CreateRandom(), ActivityTraceFlags.None); - var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var span = (Span) new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .AddLink(linkContext) .StartSpan(); @@ -690,7 +688,7 @@ public void StartSpan_WithLinkFromSpanContext() public void StartRootSpan_WithSpecifiedSampler() { // Apply given sampler before default sampler for root spans. - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetNoParent() .SetSampler(Samplers.NeverSample) @@ -704,7 +702,7 @@ public void StartRootSpan_WithSpecifiedSampler() public void StartRootSpan_WithoutSpecifiedSampler() { // Apply default sampler (always true in the tests) for root spans. - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetNoParent() .StartSpan(); @@ -716,7 +714,7 @@ public void StartRootSpan_WithoutSpecifiedSampler() [Fact] public void StartRemoteChildSpan_WithSpecifiedSampler() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.AlwaysSample) .SetNoParent() @@ -725,7 +723,7 @@ public void StartRemoteChildSpan_WithSpecifiedSampler() Assert.True(rootSpan.Context.IsValid); Assert.True((rootSpan.Context.TraceOptions & ActivityTraceFlags.Recorded) != 0); // Apply given sampler before default sampler for spans with remote parent. - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetParent(rootSpan.Context) @@ -739,7 +737,7 @@ public void StartRemoteChildSpan_WithSpecifiedSampler() [Fact] public void StartRemoteChildSpan_WithoutSpecifiedSampler() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetNoParent() @@ -748,7 +746,7 @@ public void StartRemoteChildSpan_WithoutSpecifiedSampler() Assert.True(rootSpan.Context.IsValid); Assert.True((rootSpan.Context.TraceOptions & ActivityTraceFlags.Recorded) == 0); // Apply default sampler (always true in the tests) for spans with remote parent. - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(rootSpan.Context) .StartSpan(); @@ -761,7 +759,7 @@ public void StartRemoteChildSpan_WithoutSpecifiedSampler() [Fact] public void StartChildSpan_WithSpecifiedSampler() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.AlwaysSample) .SetNoParent() @@ -771,7 +769,7 @@ public void StartChildSpan_WithSpecifiedSampler() Assert.True((rootSpan.Context.TraceOptions & ActivityTraceFlags.Recorded) != 0); // Apply the given sampler for child spans. - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetParent(rootSpan) @@ -785,7 +783,7 @@ public void StartChildSpan_WithSpecifiedSampler() [Fact] public void StartChildSpan_WithoutSpecifiedSampler() { - var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetNoParent() @@ -795,7 +793,7 @@ public void StartChildSpan_WithoutSpecifiedSampler() Assert.True((rootSpan.Context.TraceOptions & ActivityTraceFlags.Recorded) == 0); // Don't apply the default sampler (always true) for child spans. - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(rootSpan) .StartSpan(); @@ -808,7 +806,7 @@ public void StartChildSpan_WithoutSpecifiedSampler() [Fact] public void StartChildSpan_SampledLinkedParent() { - var rootSpanUnsampled = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var rootSpanUnsampled = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.NeverSample) .SetNoParent() @@ -816,7 +814,7 @@ public void StartChildSpan_SampledLinkedParent() Assert.True((rootSpanUnsampled.Context.TraceOptions & ActivityTraceFlags.Recorded) == 0); var rootSpanSampled = - new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetSampler(Samplers.AlwaysSample) .SetNoParent() @@ -824,7 +822,7 @@ public void StartChildSpan_SampledLinkedParent() Assert.True((rootSpanSampled.Context.TraceOptions & ActivityTraceFlags.Recorded) != 0); // Sampled because the linked parent is sampled. - var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + var childSpan = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .AddLink(new Link(rootSpanSampled.Context)) .SetParent(rootSpanUnsampled) @@ -846,7 +844,7 @@ public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() // If parent is sampled then the remote child must be sampled. var childSpan = - new SpanBuilder(SpanName, spanProcessor, new TraceConfig(ProbabilitySampler.Create(0.1)), Resource.Empty) + new SpanBuilder(SpanName, spanProcessor, new TracerConfiguration(ProbabilitySampler.Create(0.1)), Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(new SpanContext( traceId, @@ -861,7 +859,7 @@ public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() // If parent is not sampled then the remote child must be not sampled. childSpan = - new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty) + new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty) .SetSpanKind(SpanKind.Internal) .SetParent(new SpanContext( traceId, @@ -878,11 +876,11 @@ public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() [Fact] public void SpanBuilder_BadArguments() { - Assert.Throws(() => new SpanBuilder(null, spanProcessor, alwaysSampleTraceConfig, Resource.Empty)); - Assert.Throws(() => new SpanBuilder(SpanName, null, alwaysSampleTraceConfig, Resource.Empty)); + Assert.Throws(() => new SpanBuilder(null, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty)); + Assert.Throws(() => new SpanBuilder(SpanName, null, alwaysSampleTracerConfiguration, Resource.Empty)); Assert.Throws(() => new SpanBuilder(SpanName, spanProcessor, null, Resource.Empty)); - var spanBuilder = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTraceConfig, Resource.Empty); + var spanBuilder = new SpanBuilder(SpanName, spanProcessor, alwaysSampleTracerConfiguration, Resource.Empty); Assert.Throws(() => spanBuilder.SetParent((ISpan)null)); Assert.Throws(() => spanBuilder.SetParent((SpanContext)null)); Assert.Throws(() => spanBuilder.SetParent((Activity)null)); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs index ca513910f54..96b8200c0a5 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs @@ -14,8 +14,6 @@ // limitations under the License. // -using OpenTelemetry.Resources; - namespace OpenTelemetry.Trace.Test { using System; @@ -27,9 +25,10 @@ namespace OpenTelemetry.Trace.Test using OpenTelemetry.Abstractions.Utils; using OpenTelemetry.Tests; using OpenTelemetry.Trace; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Sampler; + using OpenTelemetry.Resources; using Xunit; public class SpanTest : IDisposable @@ -78,7 +77,7 @@ public void GetSpanContextFromActivity() activity, tracestate, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, false, @@ -103,7 +102,7 @@ public void GetSpanContextFromActivityRecordedWithParent() activity, tracestate, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, default, false, @@ -129,7 +128,7 @@ public void NoEventsRecordedAfterEnd() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, spanStartTime, false, @@ -170,7 +169,7 @@ public void ImplicitTimestamps() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), false, @@ -201,7 +200,7 @@ public async Task ActiveSpan_Properties() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, spanStartTime, false, @@ -274,7 +273,7 @@ public async Task EndedSpan_Properties() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, spanStartTime, false, @@ -339,7 +338,7 @@ public void Status_ViaSetStatus() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), false, @@ -366,7 +365,7 @@ public void status_ViaEndSpanOptions() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), false, @@ -390,7 +389,7 @@ public void DroppingAttributes() activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; var maxNumberOfAttributes = 8; - var traceConfig = new TraceConfig(Samplers.AlwaysSample, 8 , 128, 32); + var traceConfig = new TracerConfiguration(Samplers.AlwaysSample, 8 , 128, 32); var span = new Span( activity, null, @@ -441,7 +440,7 @@ public void DroppingAndAddingAttributes() activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; var maxNumberOfAttributes = 8; - var traceConfig = new TraceConfig(Samplers.AlwaysSample, maxNumberOfAttributes, 128, 32); + var traceConfig = new TracerConfiguration(Samplers.AlwaysSample, maxNumberOfAttributes, 128, 32); var span = new Span( activity, null, @@ -509,7 +508,7 @@ public async Task DroppingEvents() activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; var maxNumberOfEvents = 8; - var traceConfig = new TraceConfig(Samplers.AlwaysSample, 32, maxNumberOfEvents, 32); + var traceConfig = new TracerConfiguration(Samplers.AlwaysSample, 32, maxNumberOfEvents, 32); var span = new Span( activity, null, @@ -552,7 +551,7 @@ public void DroppingLinks() activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded; var maxNumberOfLinks = 8; - var traceConfig = new TraceConfig(Samplers.AlwaysSample, 32, 128, maxNumberOfLinks); + var traceConfig = new TracerConfiguration(Samplers.AlwaysSample, 32, 128, maxNumberOfLinks); var span = new Span( activity, null, @@ -594,7 +593,7 @@ public void BadArguments() activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), false, @@ -631,7 +630,7 @@ public void EndSpanStopsActivity(bool recordEvents) activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), ownsActivity: true, @@ -657,7 +656,7 @@ public void EndSpanDoesNotStopActivityWhenDoesNotOwnIt(bool recordEvents) activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), ownsActivity: false, @@ -686,7 +685,7 @@ public void EndSpanStopActivity_NotCurrentActivity(bool recordEvents, bool ownsA activity, null, SpanKind.Internal, - TraceConfig.Default, + new TracerConfiguration(), spanProcessor, PreciseTimestamp.GetUtcNow(), ownsActivity: ownsActivity, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs index d0447e937e6..4c70f9719ae 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs @@ -20,7 +20,7 @@ namespace OpenTelemetry.Trace.Test { using System; - using OpenTelemetry.Trace.Config; + using OpenTelemetry.Trace.Configuration; using OpenTelemetry.Trace.Export; using OpenTelemetry.Trace.Sampler; @@ -30,15 +30,15 @@ public class TracerTest { private const string SpanName = "MySpanName"; private readonly SpanProcessor spanProcessor; - private readonly TraceConfig traceConfig; + private readonly TracerConfiguration tracerConfiguration; private readonly Tracer tracer; public TracerTest() { spanProcessor = new SimpleSpanProcessor(new NoopSpanExporter()); - traceConfig = TraceConfig.Default; - tracer = new Tracer(spanProcessor, traceConfig, Resource.Empty); + tracerConfiguration = new TracerConfiguration(); + tracer = new Tracer(spanProcessor, tracerConfiguration, Resource.Empty); } [Fact] @@ -52,17 +52,17 @@ public void CreateSpanBuilder() public void BadConstructorArgumentsThrow() { var noopProc = new SimpleSpanProcessor(new NoopSpanExporter()); - Assert.Throws(() => new Tracer(null, TraceConfig.Default, Resource.Empty)); - Assert.Throws(() => new Tracer(null, TraceConfig.Default, new BinaryFormat(), new TraceContextFormat(), Resource.Empty)); + Assert.Throws(() => new Tracer(null, new TracerConfiguration(), Resource.Empty)); + Assert.Throws(() => new Tracer(null, new TracerConfiguration(), new BinaryFormat(), new TraceContextFormat(), Resource.Empty)); Assert.Throws(() => new Tracer(noopProc, null, Resource.Empty)); Assert.Throws(() => new Tracer(noopProc, null, new BinaryFormat(), new TraceContextFormat(), Resource.Empty)); - Assert.Throws(() => new Tracer(noopProc, TraceConfig.Default, null, new TraceContextFormat(), Resource.Empty)); - Assert.Throws(() => new Tracer(noopProc, TraceConfig.Default, new BinaryFormat(), null, Resource.Empty)); + Assert.Throws(() => new Tracer(noopProc, new TracerConfiguration(), null, new TraceContextFormat(), Resource.Empty)); + Assert.Throws(() => new Tracer(noopProc, new TracerConfiguration(), new BinaryFormat(), null, Resource.Empty)); - Assert.Throws(() => new Tracer(noopProc, TraceConfig.Default, null)); - Assert.Throws(() => new Tracer(noopProc, TraceConfig.Default, new BinaryFormat(), new TraceContextFormat(), null)); + Assert.Throws(() => new Tracer(noopProc, new TracerConfiguration(), null)); + Assert.Throws(() => new Tracer(noopProc, new TracerConfiguration(), new BinaryFormat(), new TraceContextFormat(), null)); } [Fact] @@ -109,17 +109,17 @@ public void GetBinaryFormat() [Fact] public void GetActiveConfig() { - var config = new TraceConfig(Samplers.NeverSample); + var config = new TracerConfiguration(Samplers.NeverSample); var tracer = new Tracer(spanProcessor, config, Resource.Empty); - Assert.Equal(config, tracer.ActiveTraceConfig); + Assert.Equal(config, tracer.ActiveTracerConfiguration); } [Fact] public void SetActiveConfig() { - var config = new TraceConfig(Samplers.NeverSample); - tracer.ActiveTraceConfig = config; - Assert.Equal(config, tracer.ActiveTraceConfig); + var config = new TracerConfiguration(Samplers.NeverSample); + tracer.ActiveTracerConfiguration = config; + Assert.Equal(config, tracer.ActiveTracerConfiguration); } // TODO test for sampler diff --git a/test/OpenTelemetry.Tests/Impl/Trace/TracingTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/TracingTest.cs index df59269f6ad..7eee5f90e07 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/TracingTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/TracingTest.cs @@ -14,6 +14,8 @@ // limitations under the License. // +using OpenTelemetry.Trace.Sampler.Internal; + namespace OpenTelemetry.Trace.Test { using OpenTelemetry.Trace.Config; @@ -34,11 +36,13 @@ public void DefaultSpanProcessor() Assert.Equal(typeof(BatchingSpanProcessor), Tracing.SpanProcessor.GetType()); } - [Fact] public void DefaultTraceConfig() { - Assert.Same(TraceConfig.Default, Tracing.TraceConfig); + Assert.IsType(Tracing.TracerConfiguration.Sampler); + Assert.Equal(32, Tracing.TracerConfiguration.MaxNumberOfAttributes); + Assert.Equal(128, Tracing.TracerConfiguration.MaxNumberOfEvents); + Assert.Equal(32, Tracing.TracerConfiguration.MaxNumberOfLinks); } } } diff --git a/test/TestApp.AspNetCore.2.0/Startup.cs b/test/TestApp.AspNetCore.2.0/Startup.cs index e7df0cb3de4..befa4596d5f 100644 --- a/test/TestApp.AspNetCore.2.0/Startup.cs +++ b/test/TestApp.AspNetCore.2.0/Startup.cs @@ -25,7 +25,7 @@ using OpenTelemetry.Trace.Sampler; using System.Net.Http; using OpenTelemetry.Exporter.Zipkin; -using OpenTelemetry.Trace.Config; +using OpenTelemetry.Trace.Configuration; namespace TestApp.AspNetCore._2._0 { @@ -53,7 +53,7 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton(new ZipkinTraceExporterOptions { ServiceName = "tracing-to-zipkin-service" }); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); }