Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IServiceProvider in AddOpenTelemetryTracing #2018

Closed
dgarciarubio opened this issue Apr 28, 2021 · 4 comments
Closed

Use IServiceProvider in AddOpenTelemetryTracing #2018

dgarciarubio opened this issue Apr 28, 2021 · 4 comments
Labels
question Further information is requested

Comments

@dgarciarubio
Copy link

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?
@dgarciarubio dgarciarubio added the question Further information is requested label Apr 28, 2021
@dgarciarubio
Copy link
Author

Maybe this can be solved with #2011

@dgarciarubio
Copy link
Author

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.

@CodeBlanch
Copy link
Member

@dgarciarubio I added some documentation in the README on #2080 please check it out and let me know what you think. I agree with you in this case it was nicer before but if we start with the IServiceProvider then TracerProviderBuilder extensions can't register anything with the IServiceCollection. Basically, the "Building Extension Methods" section in the README was impossible before the change.

@CodeBlanch
Copy link
Member

README updates are now live: https:/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Extensions.Hosting/README.md

I'm going to close this but feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants