From c13c4629290c3a979bbe6218d0d34e06c16700e8 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 14 Sep 2022 16:01:02 -0700 Subject: [PATCH] Tests. --- .../HttpClientTests.Basic.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs index c06a18bc89f..3b49cac0348 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs @@ -19,6 +19,7 @@ using System.Linq; using System.Net.Http; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Moq; using OpenTelemetry.Context.Propagation; using OpenTelemetry.Instrumentation.Http.Implementation; @@ -47,6 +48,27 @@ public HttpClientTests() this.url = $"http://{host}:{port}/"; } + [Fact] + public void AddHttpClientInstrumentation_NamedOptions() + { + int defaultExporterOptionsConfigureOptionsInvocations = 0; + int namedExporterOptionsConfigureOptionsInvocations = 0; + + using var tracerProvider = Sdk.CreateTracerProviderBuilder() + .ConfigureServices(services => + { + services.Configure(o => defaultExporterOptionsConfigureOptionsInvocations++); + + services.Configure("Instrumentation2", o => namedExporterOptionsConfigureOptionsInvocations++); + }) + .AddHttpClientInstrumentation() + .AddHttpClientInstrumentation("Instrumentation2", configureHttpClientInstrumentationOptions: null) + .Build(); + + Assert.Equal(1, defaultExporterOptionsConfigureOptionsInvocations); + Assert.Equal(1, namedExporterOptionsConfigureOptionsInvocations); + } + [Fact] public void AddHttpClientInstrumentation_BadArgs() {