-
Notifications
You must be signed in to change notification settings - Fork 0
Expose endpoint for dotnet counters
Saar Shen edited this page Apr 1, 2023
·
1 revision
Exposing an endpoint for dotnet-counters
is easy. Follow these steps:
-
Add NuGet package:
-
Update the code in
Program.cs
:var builder = WebApplication.CreateBuilder(args); ... // Add dotnet-counters services builder.Services.AddDotNetCounters(); var app = builder.Build(); ... // Expose an endpoint at `/dotnet-counters` app.MapDotNetCounters("/dotnet-counters"); app.Run();
-
Hit the endpoint:
- Run your app, assuming its hosted at
http://localhost:5555
. - Invoke:
PUT http://localhost:5555/dotnet-counters, with body:
{ "isEnabled": true, "invokingSecret": "1111" }
- Run your app, assuming its hosted at
Notes: There will be no output, yet, since there are no sinks.
Please refer to [ues dotnet-counters local file sink] or [use dotnet-counters azure blob sink] for how to configure the outputs.