diff --git a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt index 017784ab98f..ad9244f098c 100644 --- a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt @@ -11,8 +11,6 @@ OpenTelemetry.Metrics.HistogramConfiguration OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool OpenTelemetry.OpenTelemetryBuilder OpenTelemetry.OpenTelemetryBuilder.ConfigureResource(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! @@ -21,8 +19,6 @@ OpenTelemetry.OpenTelemetryBuilder.WithMetrics() -> OpenTelemetry.OpenTelemetryB OpenTelemetry.OpenTelemetryBuilder.WithMetrics(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing() -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! OpenTelemetry.OpenTelemetryServiceCollectionExtensions static OpenTelemetry.OpenTelemetryServiceCollectionExtensions.AddOpenTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> OpenTelemetry.OpenTelemetryBuilder! static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddReader(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder! diff --git a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt index 017784ab98f..ad9244f098c 100644 --- a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -11,8 +11,6 @@ OpenTelemetry.Metrics.HistogramConfiguration OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool OpenTelemetry.OpenTelemetryBuilder OpenTelemetry.OpenTelemetryBuilder.ConfigureResource(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! @@ -21,8 +19,6 @@ OpenTelemetry.OpenTelemetryBuilder.WithMetrics() -> OpenTelemetry.OpenTelemetryB OpenTelemetry.OpenTelemetryBuilder.WithMetrics(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing() -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! OpenTelemetry.OpenTelemetryServiceCollectionExtensions static OpenTelemetry.OpenTelemetryServiceCollectionExtensions.AddOpenTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> OpenTelemetry.OpenTelemetryBuilder! static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddReader(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder! diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 017784ab98f..ad9244f098c 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -11,8 +11,6 @@ OpenTelemetry.Metrics.HistogramConfiguration OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool OpenTelemetry.OpenTelemetryBuilder OpenTelemetry.OpenTelemetryBuilder.ConfigureResource(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! @@ -21,8 +19,6 @@ OpenTelemetry.OpenTelemetryBuilder.WithMetrics() -> OpenTelemetry.OpenTelemetryB OpenTelemetry.OpenTelemetryBuilder.WithMetrics(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing() -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! OpenTelemetry.OpenTelemetryServiceCollectionExtensions static OpenTelemetry.OpenTelemetryServiceCollectionExtensions.AddOpenTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> OpenTelemetry.OpenTelemetryBuilder! static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddReader(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder! diff --git a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index 017784ab98f..ad9244f098c 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -11,8 +11,6 @@ OpenTelemetry.Metrics.HistogramConfiguration OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! -OpenTelemetry.Metrics.MeterProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool OpenTelemetry.OpenTelemetryBuilder OpenTelemetry.OpenTelemetryBuilder.ConfigureResource(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! @@ -21,8 +19,6 @@ OpenTelemetry.OpenTelemetryBuilder.WithMetrics() -> OpenTelemetry.OpenTelemetryB OpenTelemetry.OpenTelemetryBuilder.WithMetrics(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing() -> OpenTelemetry.OpenTelemetryBuilder! OpenTelemetry.OpenTelemetryBuilder.WithTracing(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureBuilder(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -OpenTelemetry.Trace.TracerProviderBuilderBase.ConfigureServices(System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! OpenTelemetry.OpenTelemetryServiceCollectionExtensions static OpenTelemetry.OpenTelemetryServiceCollectionExtensions.AddOpenTelemetry(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> OpenTelemetry.OpenTelemetryBuilder! static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddReader(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder! diff --git a/src/OpenTelemetry/Metrics/Builder/MeterProviderBuilderBase.cs b/src/OpenTelemetry/Metrics/Builder/MeterProviderBuilderBase.cs index 4b75d85acff..15a537916b8 100644 --- a/src/OpenTelemetry/Metrics/Builder/MeterProviderBuilderBase.cs +++ b/src/OpenTelemetry/Metrics/Builder/MeterProviderBuilderBase.cs @@ -70,7 +70,7 @@ public override MeterProviderBuilder AddInstrumentation(Func + this.ConfigureBuilderInternal((sp, builder) => { builder.AddInstrumentation(instrumentationFactory); }); @@ -83,7 +83,7 @@ public override MeterProviderBuilder AddMeter(params string[] names) { Guard.ThrowIfNull(names); - this.ConfigureBuilder((sp, builder) => + this.ConfigureBuilderInternal((sp, builder) => { builder.AddMeter(names); }); @@ -92,40 +92,16 @@ public override MeterProviderBuilder AddMeter(params string[] names) } /// - public MeterProviderBuilder ConfigureBuilder(Action configure) - { - var services = this.services; - - if (services == null) - { - throw new NotSupportedException("Builder cannot be configured during MeterProvider construction."); - } - - services.ConfigureOpenTelemetryMeterProvider(configure); - - return this; - } + MeterProviderBuilder IMeterProviderBuilder.ConfigureServices(Action configure) + => this.ConfigureServicesInternal(configure); /// - public MeterProviderBuilder ConfigureServices(Action configure) - { - Guard.ThrowIfNull(configure); - - var services = this.services; - - if (services == null) - { - throw new NotSupportedException("Services cannot be configured during MeterProvider construction."); - } - - configure(services); - - return this; - } + MeterProviderBuilder IMeterProviderBuilder.ConfigureBuilder(Action configure) + => this.ConfigureBuilderInternal(configure); /// MeterProviderBuilder IDeferredMeterProviderBuilder.Configure(Action configure) - => this.ConfigureBuilder(configure); + => this.ConfigureBuilderInternal(configure); internal MeterProvider InvokeBuild() => this.Build(); @@ -159,4 +135,34 @@ protected MeterProvider Build() return new MeterProviderSdk(serviceProvider, ownsServiceProvider: true); } + + private MeterProviderBuilder ConfigureBuilderInternal(Action configure) + { + var services = this.services; + + if (services == null) + { + throw new NotSupportedException("Builder cannot be configured during MeterProvider construction."); + } + + services.ConfigureOpenTelemetryMeterProvider(configure); + + return this; + } + + private MeterProviderBuilder ConfigureServicesInternal(Action configure) + { + Guard.ThrowIfNull(configure); + + var services = this.services; + + if (services == null) + { + throw new NotSupportedException("Services cannot be configured during MeterProvider construction."); + } + + configure(services); + + return this; + } } diff --git a/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderBase.cs b/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderBase.cs index ad9e1b9560f..1cad84653eb 100644 --- a/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderBase.cs +++ b/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderBase.cs @@ -73,7 +73,7 @@ public override TracerProviderBuilder AddInstrumentation(Func< { Guard.ThrowIfNull(instrumentationFactory); - this.ConfigureBuilder((sp, builder) => + this.ConfigureBuilderInternal((sp, builder) => { builder.AddInstrumentation(instrumentationFactory); }); @@ -86,7 +86,7 @@ public override TracerProviderBuilder AddSource(params string[] names) { Guard.ThrowIfNull(names); - this.ConfigureBuilder((sp, builder) => + this.ConfigureBuilderInternal((sp, builder) => { builder.AddSource(names); }); @@ -99,7 +99,7 @@ public override TracerProviderBuilder AddLegacySource(string operationName) { Guard.ThrowIfNullOrWhitespace(operationName); - this.ConfigureBuilder((sp, builder) => + this.ConfigureBuilderInternal((sp, builder) => { builder.AddLegacySource(operationName); }); @@ -108,40 +108,16 @@ public override TracerProviderBuilder AddLegacySource(string operationName) } /// - public TracerProviderBuilder ConfigureBuilder(Action configure) - { - var services = this.services; - - if (services == null) - { - throw new NotSupportedException("Builder cannot be configured during TracerProvider construction."); - } - - services.ConfigureOpenTelemetryTracerProvider(configure); - - return this; - } + TracerProviderBuilder ITracerProviderBuilder.ConfigureServices(Action configure) + => this.ConfigureServicesInternal(configure); /// - public TracerProviderBuilder ConfigureServices(Action configure) - { - Guard.ThrowIfNull(configure); - - var services = this.services; - - if (services == null) - { - throw new NotSupportedException("Services cannot be configured during TracerProvider construction."); - } - - configure(services); - - return this; - } + TracerProviderBuilder ITracerProviderBuilder.ConfigureBuilder(Action configure) + => this.ConfigureBuilderInternal(configure); /// TracerProviderBuilder IDeferredTracerProviderBuilder.Configure(Action configure) - => this.ConfigureBuilder(configure); + => this.ConfigureBuilderInternal(configure); internal TracerProvider InvokeBuild() => this.Build(); @@ -162,7 +138,7 @@ protected TracerProviderBuilder AddInstrumentation( Guard.ThrowIfNullOrWhitespace(instrumentationVersion); Guard.ThrowIfNull(instrumentationFactory); - return this.ConfigureBuilder((sp, builder) => + return this.ConfigureBuilderInternal((sp, builder) => { if (builder is TracerProviderBuilderSdk tracerProviderBuilderState) { @@ -203,4 +179,34 @@ protected TracerProvider Build() return new TracerProviderSdk(serviceProvider, ownsServiceProvider: true); } + + private TracerProviderBuilder ConfigureBuilderInternal(Action configure) + { + var services = this.services; + + if (services == null) + { + throw new NotSupportedException("Builder cannot be configured during TracerProvider construction."); + } + + services.ConfigureOpenTelemetryTracerProvider(configure); + + return this; + } + + private TracerProviderBuilder ConfigureServicesInternal(Action configure) + { + Guard.ThrowIfNull(configure); + + var services = this.services; + + if (services == null) + { + throw new NotSupportedException("Services cannot be configured during TracerProvider construction."); + } + + configure(services); + + return this; + } }