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

Configuration of .NET 7+ using HostApplicationBuilder #2262

Closed
stevejgordon opened this issue Jan 24, 2024 · 0 comments · Fixed by #2326
Closed

Configuration of .NET 7+ using HostApplicationBuilder #2262

stevejgordon opened this issue Jan 24, 2024 · 0 comments · Fixed by #2326
Assignees
Labels
agent-dotnet enhancement New feature or request
Milestone

Comments

@stevejgordon
Copy link
Contributor

stevejgordon commented Jan 24, 2024

Since .NET 7, the preferred use of the generic host has been first to create a HostApplicationBuilder, which implements IHostApplicationBuilder, from the static method on the Host type. e.g.

HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHostedService<Worker>();
IHost host = builder.Build();

We do not currently provide extension methods to support the registration of the APM agent.

It's possible to work around this by manually creating an APM instance (although that won't include hooks such as integrating with the logging extensions) or switching to the older (no longer preferred) Host.CreateDefaultBuilder style code instead.

Implementing the current behaviour is complicated since the new flow doesn't expose an intermediate IServiceProvider.

A further scenario we should consider is enabling APM in .NET Maui apps, which use the MauiAppBuilder.

We should likely provide an IServiceCollection extension method to enable APM.

@stevejgordon stevejgordon added the enhancement New feature or request label Jan 24, 2024
@stevejgordon stevejgordon added this to the 8.14 milestone Mar 28, 2024
@stevejgordon stevejgordon changed the title Configuration of .NET 7+ Worker Services Configuration of .NET 7+ using HostApplicationBuilder Mar 28, 2024
@stevejgordon stevejgordon self-assigned this Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-dotnet enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant