♻️ Add services to container in Pass

This commit is contained in:
2025-07-12 11:58:38 +08:00
parent ba49d1c7a7
commit 0318364bcf
8 changed files with 406 additions and 15 deletions

View File

@ -0,0 +1,40 @@
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Prometheus;
using Prometheus.SystemMetrics;
namespace DysonNetwork.Pass.Startup;
public static class MetricsConfiguration
{
public static IServiceCollection AddAppMetrics(this IServiceCollection services)
{
// Prometheus
services.UseHttpClientMetrics();
services.AddHealthChecks();
services.AddSystemMetrics();
services.AddPrometheusEntityFrameworkMetrics();
services.AddPrometheusAspNetCoreMetrics();
services.AddPrometheusHttpClientMetrics();
// OpenTelemetry
services.AddOpenTelemetry()
.WithTracing(tracing =>
{
tracing
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddOtlpExporter();
})
.WithMetrics(metrics =>
{
metrics
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation()
.AddOtlpExporter();
});
return services;
}
}