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

IWebHostBuilder extensions register multiple IConfigureOptions<SentryAspNetCoreOptions> #3906

Open
jamescrosswell opened this issue Jan 20, 2025 · 0 comments

Comments

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented Jan 20, 2025

When using the IWebHostBuilder extensions to configure Sentry in ASP.NET Core, three separate IConfigureOptions<SentryAspNetCoreOptions> instances are registered with the Services collection.

I think at least one of these is redundant.

Registration 1

_ = logging.Services.AddSingleton<IConfigureOptions<SentryAspNetCoreOptions>>(_ =>
new SentryAspNetCoreOptionsSetup(section)
);

Registration 2

_ = logging.Services
.AddSingleton<IConfigureOptions<SentryAspNetCoreOptions>, SentryAspNetCoreOptionsSetup>();

Registration 3

sentryBuilder.AddSentryOptions(options =>
{
configureOptions?.Invoke(context, options);
options.SetEnvironment(context.HostingEnvironment);
});

builder.Services.Configure(configureOptions);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant