rework metrics

This commit is contained in:
Stanley Dimant
2022-08-26 02:22:19 +02:00
parent 7c1395df77
commit ace31926db
21 changed files with 179 additions and 244 deletions

View File

@@ -1,6 +1,7 @@
using Grpc.Net.Client.Configuration;
using MareSynchronosShared.Authentication;
using MareSynchronosShared.Data;
using MareSynchronosShared.Metrics;
using MareSynchronosShared.Protos;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
@@ -10,7 +11,9 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Prometheus;
using System;
using System.Collections.Generic;
namespace MareSynchronosStaticFilesServer;
@@ -44,6 +47,13 @@ public class Startup
}
};
services.AddSingleton(new MareMetrics(new List<string> {
}, new List<string>
{
MetricsAPI.GaugeFilesTotalSize,
MetricsAPI.GaugeFilesTotal
}));
services.AddGrpcClient<AuthService.AuthServiceClient>(c =>
{
c.Address = new Uri(mareSettings.GetValue<string>("ServiceAddress"));
@@ -51,13 +61,6 @@ public class Startup
{
c.ServiceConfig = new ServiceConfig { MethodConfigs = { defaultMethodConfig } };
});
services.AddGrpcClient<MetricsService.MetricsServiceClient>(c =>
{
c.Address = new Uri(mareSettings.GetValue<string>("ServiceAddress"));
}).ConfigureChannel(c =>
{
c.ServiceConfig = new ServiceConfig { MethodConfigs = { defaultMethodConfig } };
});
services.AddDbContextPool<MareDbContext>(options =>
{
@@ -89,6 +92,9 @@ public class Startup
app.UseRouting();
var metricServer = new KestrelMetricServer(4982);
metricServer.Start();
app.UseAuthentication();
app.UseAuthorization();