Remove Prometheus
This commit is contained in:
parent
fc5ff87c8f
commit
c031d2bfb4
2 changed files with 2 additions and 22 deletions
|
@ -15,8 +15,6 @@ using Geekbot.net.Lib.Logger;
|
||||||
using Geekbot.net.Lib.ReactionListener;
|
using Geekbot.net.Lib.ReactionListener;
|
||||||
using Geekbot.net.Lib.UserRepository;
|
using Geekbot.net.Lib.UserRepository;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Prometheus;
|
|
||||||
|
|
||||||
namespace Geekbot.net
|
namespace Geekbot.net
|
||||||
{
|
{
|
||||||
public class Handlers
|
public class Handlers
|
||||||
|
@ -24,7 +22,6 @@ namespace Geekbot.net
|
||||||
private readonly DatabaseContext _database;
|
private readonly DatabaseContext _database;
|
||||||
private readonly IDiscordClient _client;
|
private readonly IDiscordClient _client;
|
||||||
private readonly IGeekbotLogger _logger;
|
private readonly IGeekbotLogger _logger;
|
||||||
private readonly IAlmostRedis _redis;
|
|
||||||
private readonly IServiceProvider _servicesProvider;
|
private readonly IServiceProvider _servicesProvider;
|
||||||
private readonly CommandService _commands;
|
private readonly CommandService _commands;
|
||||||
private readonly IUserRepository _userRepository;
|
private readonly IUserRepository _userRepository;
|
||||||
|
@ -33,10 +30,7 @@ namespace Geekbot.net
|
||||||
private readonly RestApplication _applicationInfo;
|
private readonly RestApplication _applicationInfo;
|
||||||
private readonly List<ulong> _ignoredServers;
|
private readonly List<ulong> _ignoredServers;
|
||||||
|
|
||||||
private readonly Counter _messageCounterPrometheus =
|
public Handlers(DatabaseInitializer databaseInitializer, IDiscordClient client, IGeekbotLogger logger,
|
||||||
Metrics.CreateCounter("messages", "Number of discord messages", new CounterConfiguration() {LabelNames = new[] {"guild", "channel", "user"}});
|
|
||||||
|
|
||||||
public Handlers(DatabaseInitializer databaseInitializer, IDiscordClient client, IGeekbotLogger logger, IAlmostRedis redis,
|
|
||||||
IServiceProvider servicesProvider, CommandService commands, IUserRepository userRepository,
|
IServiceProvider servicesProvider, CommandService commands, IUserRepository userRepository,
|
||||||
IReactionListener reactionListener, RestApplication applicationInfo)
|
IReactionListener reactionListener, RestApplication applicationInfo)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +38,6 @@ namespace Geekbot.net
|
||||||
_messageCounterDatabaseContext = databaseInitializer.Initialize();
|
_messageCounterDatabaseContext = databaseInitializer.Initialize();
|
||||||
_client = client;
|
_client = client;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_redis = redis;
|
|
||||||
_servicesProvider = servicesProvider;
|
_servicesProvider = servicesProvider;
|
||||||
_commands = commands;
|
_commands = commands;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
|
@ -150,8 +143,6 @@ namespace Geekbot.net
|
||||||
_messageCounterDatabaseContext.SaveChanges();
|
_messageCounterDatabaseContext.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
_messageCounterPrometheus.WithLabels(channel.Guild.Id.ToString(), channel.Id.ToString(), message.Author.Id.ToString()).Inc();
|
|
||||||
|
|
||||||
if (message.Author.IsBot) return;
|
if (message.Author.IsBot) return;
|
||||||
_logger.Information(LogSource.Message, message.Content, SimpleConextConverter.ConvertSocketMessage(message));
|
_logger.Information(LogSource.Message, message.Content, SimpleConextConverter.ConvertSocketMessage(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ using Geekbot.net.Lib.UserRepository;
|
||||||
using Geekbot.net.WebApi;
|
using Geekbot.net.WebApi;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Prometheus;
|
|
||||||
using WikipediaApi;
|
using WikipediaApi;
|
||||||
|
|
||||||
namespace Geekbot.net
|
namespace Geekbot.net
|
||||||
|
@ -173,7 +172,7 @@ namespace Geekbot.net
|
||||||
_servicesProvider = _services.BuildServiceProvider();
|
_servicesProvider = _services.BuildServiceProvider();
|
||||||
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _servicesProvider);
|
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _servicesProvider);
|
||||||
|
|
||||||
var handlers = new Handlers(_databaseInitializer, _client, _logger, _redis, _servicesProvider, _commands, _userRepository, reactionListener, applicationInfo);
|
var handlers = new Handlers(_databaseInitializer, _client, _logger, _servicesProvider, _commands, _userRepository, reactionListener, applicationInfo);
|
||||||
|
|
||||||
_client.MessageReceived += handlers.RunCommand;
|
_client.MessageReceived += handlers.RunCommand;
|
||||||
_client.MessageDeleted += handlers.MessageDeleted;
|
_client.MessageDeleted += handlers.MessageDeleted;
|
||||||
|
@ -184,8 +183,6 @@ namespace Geekbot.net
|
||||||
_client.ReactionRemoved += handlers.ReactionRemoved;
|
_client.ReactionRemoved += handlers.ReactionRemoved;
|
||||||
if (!_runParameters.InMemory) _client.MessageReceived += handlers.UpdateStats;
|
if (!_runParameters.InMemory) _client.MessageReceived += handlers.UpdateStats;
|
||||||
|
|
||||||
StartPrometheusServer();
|
|
||||||
|
|
||||||
var webserver = _runParameters.DisableApi ? Task.Delay(10) : StartWebApi();
|
var webserver = _runParameters.DisableApi ? Task.Delay(10) : StartWebApi();
|
||||||
_logger.Information(LogSource.Geekbot, "Done and ready for use");
|
_logger.Information(LogSource.Geekbot, "Done and ready for use");
|
||||||
|
|
||||||
|
@ -213,13 +210,5 @@ namespace Geekbot.net
|
||||||
WebApiStartup.StartWebApi(_logger, _runParameters, _commands, _databaseInitializer.Initialize(), _client, _globalSettings, highscoreManager);
|
WebApiStartup.StartWebApi(_logger, _runParameters, _commands, _databaseInitializer.Initialize(), _client, _globalSettings, highscoreManager);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartPrometheusServer()
|
|
||||||
{
|
|
||||||
var port = _runParameters.PrometheusPort == "12991" ? 12991 : int.Parse(_runParameters.PrometheusPort);
|
|
||||||
var server = new MetricServer(_runParameters.PrometheusHost, port);
|
|
||||||
server.Start();
|
|
||||||
_logger.Information(LogSource.Geekbot, $"Prometheus Metric Server running on {_runParameters.PrometheusHost}:{_runParameters.PrometheusPort}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue