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
Dotnet 6 Configuration #720
Comments
+1 |
@hughesjs & @krzysiek-b - What no Just in case you have not figured it out - this seems to work: var builder = WebApplication.CreateBuilder();
builder.Services
.AddMetrics(metrics)
.AddAppMetricsSystemMetricsCollector()
.AddAppMetricsCollectors();
builder.Host
.ConfigureMetrics(builder =>
{
builder.Configuration.Configure(options =>
{
options.DefaultContextLabel = "default";
});
})
.UseMetrics(options =>
{
options.EndpointOptions = endpointsOptions =>
{
endpointsOptions.MetricsTextEndpointOutputFormatter =
new MetricsPrometheusTextOutputFormatter();
};
});
var web = builder.Build();
web.Urls.Add($"http://localhost:{port}");
web.UseMetricsTextEndpoint();
await web.RunAsync(_source.Token); |
Yeah, I got it to work, but that's not really my point. A large part of the changes to dotnet 6 startup were driven by a desire to simplify things and reduce the need for chains of nested lamdas. I feel like that's something we should aspire to support. |
@hughesjs can u share some example how did you get it working and for some reasons the metrics endpoint started to serve the data in binary format when i started to use AsPrometheusPlainText or AsPrometheusProtobuf as explained here: https://www.app-metrics.io/reporting/reporters/prometheus/ |
Dotnet 6 does away with the need for complex nested lambdas etc for configuration (let's be real, that was always a terrible API).
The new hotness
WebApplication
rather thanHost
orWebHost
is great. Unfortunately, the existingConfigureMetricsWithDefaults()
doesn't work with this pattern at all.We need to update things to work better with dotnet 6
The text was updated successfully, but these errors were encountered: