Skip to content

Commit 13015d1

Browse files
phnx47sanych-sun
authored andcommitted
feat: use Metrics.DefaultCollectorRegistry by default, add overload (#2)
1 parent 84d0b2e commit 13015d1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Prometheus.Client.DependencyInjection/ServiceCollectionExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using Prometheus.Client.Abstractions;
3-
using Prometheus.Client.Collectors;
43
using Prometheus.Client.Collectors.Abstractions;
54

65
namespace Prometheus.Client.DependencyInjection
@@ -9,7 +8,12 @@ public static class ServiceCollectionExtensions
98
{
109
public static void AddMetricFactory(this IServiceCollection services)
1110
{
12-
services.AddSingleton<ICollectorRegistry, CollectorRegistry>();
11+
AddMetricFactory(services, Metrics.DefaultCollectorRegistry);
12+
}
13+
14+
public static void AddMetricFactory(this IServiceCollection services, ICollectorRegistry collectorRegistry)
15+
{
16+
services.AddSingleton(collectorRegistry);
1317
services.AddSingleton<IMetricFactory, MetricFactory>();
1418
}
1519
}

0 commit comments

Comments
 (0)