Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Standalone Kestrel server

License

NotificationsYou must be signed in to change notification settings

prom-client-net/prom-client-metricserver

Repository files navigation

cinugetnugetcodecovlicense

Extension forPrometheus.Client

Install

dotnet add package Prometheus.Client.MetricServer

Use

Examples

Simple Console App with static MetricFactory:

publicstaticvoidMain(string[]args){varoptions=newMetricServerOptions{Port=9091};varmetricServer=newMetricServer(options);metricServer.Start();varcounter=Metrics.DefaultFactory.CreateCounter("test_count","helptext");counter.Inc();metricServer.Stop();}

Worker with DIPrometheus.Client.DependencyInjection:

publicstaticasyncTaskMain(string[]args){varhost=Host.CreateDefaultBuilder(args).ConfigureServices((_,services)=>{services.AddMetricFactory();services.AddSingleton<IMetricServer>(sp=>newMetricServer(newMetricServerOptions{CollectorRegistry=sp.GetRequiredService<ICollectorRegistry>(),UseDefaultCollectors=true}));services.AddHostedService<Worker>();}).Build();varmetricServer=host.Services.GetRequiredService<IMetricServer>();try{metricServer.Start();awaithost.RunAsync();}catch(Exceptionex){Console.WriteLine("Host Terminated Unexpectedly");}finally{metricServer.Stop();}}

License

All contents of this package are licensed under theMIT license.

About

Standalone Kestrel server

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors10

Languages


[8]ページ先頭

©2009-2025 Movatter.jp