From b29d11c94b40042cd506cf78e8120ef75709da23 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 13 Sep 2022 14:28:46 -0700 Subject: [PATCH 1/3] Add named options support to jaeger provider builder extensions. --- .../.publicApi/net462/PublicAPI.Unshipped.txt | 4 +++ .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 4 +++ .../netstandard2.0/PublicAPI.Unshipped.txt | 4 +++ .../netstandard2.1/PublicAPI.Unshipped.txt | 4 +++ .../CHANGELOG.md | 5 +++ .../JaegerExporterHelperExtensions.cs | 31 ++++++++++++++++--- .../JaegerExporterTests.cs | 21 +++++++++++++ 7 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net462/PublicAPI.Unshipped.txt index e69de29bb2d..a387a9ca5e5 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net462/PublicAPI.Unshipped.txt @@ -0,0 +1,4 @@ +*REMOVED*static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net6.0/PublicAPI.Unshipped.txt index e69de29bb2d..a387a9ca5e5 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,4 @@ +*REMOVED*static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index e69de29bb2d..a387a9ca5e5 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,4 @@ +*REMOVED*static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index e69de29bb2d..a387a9ca5e5 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Jaeger/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -0,0 +1,4 @@ +*REMOVED*static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.JaegerExporterHelperExtensions.AddJaegerExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md index 659e0791b24..37294ed42e2 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* Added overloads which accept a name to the `TracerProviderBuilder` + `AddJaegerExporter` extension to allow for more fine-grained options + management + ([#XXXX](https://github.com/open-telemetry/opentelemetry-dotnet/pull/XXXX)) + ## 1.4.0-alpha.2 Released 2022-Aug-18 diff --git a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterHelperExtensions.cs index dec28c8c236..db1b770d31d 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterHelperExtensions.cs +++ b/src/OpenTelemetry.Exporter.Jaeger/JaegerExporterHelperExtensions.cs @@ -33,20 +33,43 @@ public static class JaegerExporterHelperExtensions /// Adds Jaeger exporter to the TracerProvider. /// /// builder to use. - /// Exporter configuration options. /// The instance of to chain the calls. - public static TracerProviderBuilder AddJaegerExporter(this TracerProviderBuilder builder, Action configure = null) + public static TracerProviderBuilder AddJaegerExporter(this TracerProviderBuilder builder) + => AddJaegerExporter(builder, name: null, configure: null); + + /// + /// Adds Jaeger exporter to the TracerProvider. + /// + /// builder to use. + /// Callback action for configuring . + /// The instance of to chain the calls. + public static TracerProviderBuilder AddJaegerExporter(this TracerProviderBuilder builder, Action configure) + => AddJaegerExporter(builder, name: null, configure); + + /// + /// Adds Jaeger exporter to the TracerProvider. + /// + /// builder to use. + /// Name which is used when retrieving options. + /// Callback action for configuring . + /// The instance of to chain the calls. + public static TracerProviderBuilder AddJaegerExporter( + this TracerProviderBuilder builder, + string name, + Action configure) { Guard.ThrowIfNull(builder); + name ??= Options.DefaultName; + if (configure != null) { - builder.ConfigureServices(services => services.Configure(configure)); + builder.ConfigureServices(services => services.Configure(name, configure)); } return builder.ConfigureBuilder((sp, builder) => { - var options = sp.GetRequiredService>().Value; + var options = sp.GetRequiredService>().Get(name); AddJaegerExporter(builder, options, sp); }); diff --git a/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs b/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs index 5d018bcf8c1..1a7791bdf5d 100644 --- a/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs @@ -33,6 +33,27 @@ namespace OpenTelemetry.Exporter.Jaeger.Tests { public class JaegerExporterTests { + [Fact] + public void AddAddZipkinExporterNamedOptionsSupported() + { + int defaultExporterOptionsConfigureOptionsInvocations = 0; + int namedExporterOptionsConfigureOptionsInvocations = 0; + + using var tracerProvider = Sdk.CreateTracerProviderBuilder() + .ConfigureServices(services => + { + services.Configure(o => defaultExporterOptionsConfigureOptionsInvocations++); + + services.Configure("Exporter2", o => namedExporterOptionsConfigureOptionsInvocations++); + }) + .AddJaegerExporter() + .AddJaegerExporter("Exporter2", o => { }) + .Build(); + + Assert.Equal(1, defaultExporterOptionsConfigureOptionsInvocations); + Assert.Equal(1, namedExporterOptionsConfigureOptionsInvocations); + } + [Fact] public void JaegerExporter_BadArgs() { From 587844bf31e4664fc83e9afc3a382c202017fe1c Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 13 Sep 2022 14:30:03 -0700 Subject: [PATCH 2/3] CHANGELOG update. --- src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md index 37294ed42e2..b040029c49a 100644 --- a/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md @@ -5,7 +5,7 @@ * Added overloads which accept a name to the `TracerProviderBuilder` `AddJaegerExporter` extension to allow for more fine-grained options management - ([#XXXX](https://github.com/open-telemetry/opentelemetry-dotnet/pull/XXXX)) + ([#3656](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3656)) ## 1.4.0-alpha.2 From bd34979b95c8d02e44b40f9d41dc855004f886c5 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Tue, 13 Sep 2022 14:41:25 -0700 Subject: [PATCH 3/3] Code review. --- test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs b/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs index 1a7791bdf5d..28baef09e66 100644 --- a/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Jaeger.Tests/JaegerExporterTests.cs @@ -34,7 +34,7 @@ namespace OpenTelemetry.Exporter.Jaeger.Tests public class JaegerExporterTests { [Fact] - public void AddAddZipkinExporterNamedOptionsSupported() + public void AddJaegerExporterNamedOptionsSupported() { int defaultExporterOptionsConfigureOptionsInvocations = 0; int namedExporterOptionsConfigureOptionsInvocations = 0;