Opentelemetry-dotnet: Use IServiceProvider in AddOpenTelemetryTracing

Created on 28 Apr 2021  路  2Comments  路  Source: open-telemetry/opentelemetry-dotnet

Question

I am using the 1.0.0-rc4 of OpenTelemetry.Extensions.Hosting. I'm trying to add redis instrumentation, but for that I need an instance of IConnectionMultiplexer. In some examples, I have seen that it can be resolved from the service provider by using the following overload of AddOpenTelemetryTracing:

services.AddOpenTelemetryTracing((serviceProvider, builder) =>
{
    builder.AddRedisInstrumentation(serviceProvider.GetRequiredService<IConnectionMultiplexer>());
}

However, this overload has disappeared in rc-4, while it was present in rc-3.

  • Is this planned to be available in the final release?
  • If not, is there any other recommended way we can solve this use case?
question

Most helpful comment

I see that this overload was dropped in #1889 in favor of

services.AddOpenTelemetryTracing(builder =>
{
    builder.configure((serviceProvider, builder) => 
    {
        //Use the service provider here to add additional configuration to the builder
    });
});

Personally, I find the previous overload of AddOpenTelemetryTracing useful, and more easily discoverable.
Anyway, if this is the new way to go, it would be useful to add examples of how to achieve this in the documentation.

All 2 comments

Maybe this can be solved with #2011

I see that this overload was dropped in #1889 in favor of

services.AddOpenTelemetryTracing(builder =>
{
    builder.configure((serviceProvider, builder) => 
    {
        //Use the service provider here to add additional configuration to the builder
    });
});

Personally, I find the previous overload of AddOpenTelemetryTracing useful, and more easily discoverable.
Anyway, if this is the new way to go, it would be useful to add examples of how to achieve this in the documentation.

Was this page helpful?
0 / 5 - 0 ratings