Skip to content

Commit

Permalink
updating prometheus configuration code sample
Browse files Browse the repository at this point in the history
  • Loading branch information
alhardy committed Nov 2, 2017
1 parent f4a7d3a commit c3bee0c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions content/reporting/reporters/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,24 @@ nuget install App.Metrics.AspNetCore
```csharp
public static class Program
{
public static IMetricsRoot Metrics { get; set; }

public static IWebHost BuildWebHost(string[] args)
{
Metrics = AppMetrics.CreateDefaultBuilder()
.OutputMetrics.AsPrometheusPlainText()
.OutputMetrics.AsPrometheusProtobuf()
.Build();

return WebHost.CreateDefaultBuilder(args)
.ConfigureMetricsWithDefaults(
builder =>
{
builder.OutputMetrics.AsPrometheusPlainText();
builder.OutputMetrics.AsPrometheusProtobuf();
})
.ConfigureMetrics(Metrics)
.UseMetrics(
options =>
{
options.EndpointOptions = endpointsOptions =>
{
endpointsOptions.MetricsTextEndpointOutputFormatter = new MetricsPrometheusTextOutputFormatter();
endpointsOptions.MetricsEndpointOutputFormatter = new MetricsPrometheusProtobufOutputFormatter();
endpointsOptions.MetricsTextEndpointOutputFormatter = Metrics.OutputMetricsFormatters.GetType<MetricsPrometheusTextOutputFormatter>();
endpointsOptions.MetricsEndpointOutputFormatter = Metrics.OutputMetricsFormatters.GetType<MetricsPrometheusProtobufOutputFormatter>();
};
})
.UseStartup<Startup>()
Expand Down

0 comments on commit c3bee0c

Please sign in to comment.