-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8239d02
commit 53a7508
Showing
9 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Diagnostics.Metrics; | ||
|
||
namespace MacroBot.Core.Metrics; | ||
|
||
public class UsersMetrics | ||
{ | ||
private readonly Counter<int> _usersCounter; | ||
|
||
public UsersMetrics(IMeterFactory meterFactory) | ||
{ | ||
var meter = meterFactory.Create("MacroBot"); | ||
_usersCounter = meter.CreateCounter<int>("macrobot.users"); | ||
} | ||
|
||
public void UserJoined() | ||
{ | ||
_usersCounter.Add(1); | ||
} | ||
|
||
public void UserLeft() | ||
{ | ||
_usersCounter.Add(-1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using OpenTelemetry.Metrics; | ||
|
||
namespace MacroBot.StartupConfig; | ||
|
||
public static class MetricsConfiguration | ||
{ | ||
public static void AddMetricsConfiguration(this IServiceCollection services) | ||
{ | ||
services.AddOpenTelemetry() | ||
.WithMetrics(builder => | ||
{ | ||
builder.AddPrometheusExporter(); | ||
|
||
builder.AddMeter( | ||
"Microsoft.AspNetCore.Hosting", | ||
"Microsoft.AspNetCore.Server.Kestrel"); | ||
builder.AddView("http.server.request.duration", | ||
new ExplicitBucketHistogramConfiguration | ||
{ | ||
Boundaries = | ||
[ | ||
0, 0.005, 0.01, 0.025, 0.05, | ||
0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 | ||
] | ||
}); | ||
}); | ||
} | ||
} |