88using Prometheus . Client ;
99using Prometheus . Client . AspNetCore ;
1010using Prometheus . Client . Collectors ;
11+ using Prometheus . Client . DependencyInjection ;
1112using Prometheus . Client . HealthChecks ;
1213
1314namespace HealthChecks ;
@@ -21,20 +22,18 @@ public Startup(IConfiguration configuration)
2122
2223 public IConfiguration Configuration { get ; }
2324
24- // This method gets called by the runtime. Use this method to add services to the container.
2525 public void ConfigureServices ( IServiceCollection services )
2626 {
2727 services . AddControllers ( ) ;
28- services . AddSingleton < ICollectorRegistry , CollectorRegistry > ( ) ;
29- services . AddSingleton < IMetricFactory , MetricFactory > ( ) ;
28+ services . AddMetricFactory ( ) ;
29+
3030 services
3131 . AddHealthChecks ( )
3232 . AddUrlGroup ( new Uri ( "https://google.com" ) , "google" , HealthStatus . Unhealthy )
3333 . AddUrlGroup ( new Uri ( "https://invalidurl" ) , "invalidurl" , HealthStatus . Degraded ) ;
3434 services . AddPrometheusHealthCheckPublisher ( ) ;
3535 }
3636
37- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3837 public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
3938 {
4039 app . UseRouting ( ) ;
@@ -46,7 +45,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4645
4746 app . UseHealthChecks ( "/hc" , new HealthCheckOptions
4847 {
49- Predicate = r => true
48+ Predicate = _ => true
5049 } ) ;
5150
5251 app . UsePrometheusServer ( ) ;
0 commit comments