Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests.
  • Loading branch information
CodeBlanch committed Sep 14, 2022
commit c13c4629290c3a979bbe6218d0d34e06c16700e8
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<HttpClientInstrumentationOptions>(o => defaultExporterOptionsConfigureOptionsInvocations++);

services.Configure<HttpClientInstrumentationOptions>("Instrumentation2", o => namedExporterOptionsConfigureOptionsInvocations++);
})
.AddHttpClientInstrumentation()
.AddHttpClientInstrumentation("Instrumentation2", configureHttpClientInstrumentationOptions: null)
.Build();

Assert.Equal(1, defaultExporterOptionsConfigureOptionsInvocations);
Assert.Equal(1, namedExporterOptionsConfigureOptionsInvocations);
}

[Fact]
public void AddHttpClientInstrumentation_BadArgs()
{
Expand Down