Track database handles over metrics
This commit is contained in:
@@ -79,7 +79,8 @@ namespace PluralKit.Bot
|
||||
.AddTransient(_ => _config.GetSection("PluralKit").Get<CoreConfig>() ?? new CoreConfig())
|
||||
.AddTransient(_ => _config.GetSection("PluralKit").GetSection("Bot").Get<BotConfig>() ?? new BotConfig())
|
||||
|
||||
.AddTransient(svc => new DbConnectionFactory(svc.GetRequiredService<CoreConfig>().Database))
|
||||
.AddSingleton<DbConnectionCountHolder>()
|
||||
.AddTransient<DbConnectionFactory>()
|
||||
|
||||
.AddSingleton<IDiscordClient, DiscordShardedClient>(_ => new DiscordShardedClient(new DiscordSocketConfig
|
||||
{
|
||||
|
||||
@@ -24,9 +24,11 @@ namespace PluralKit.Bot
|
||||
|
||||
private WebhookCacheService _webhookCache;
|
||||
|
||||
private DbConnectionCountHolder _countHolder;
|
||||
|
||||
private ILogger _logger;
|
||||
|
||||
public PeriodicStatCollector(IDiscordClient client, IMetrics metrics, SystemStore systems, MemberStore members, SwitchStore switches, MessageStore messages, ILogger logger, WebhookCacheService webhookCache)
|
||||
public PeriodicStatCollector(IDiscordClient client, IMetrics metrics, SystemStore systems, MemberStore members, SwitchStore switches, MessageStore messages, ILogger logger, WebhookCacheService webhookCache, DbConnectionCountHolder countHolder)
|
||||
{
|
||||
_client = (DiscordShardedClient) client;
|
||||
_metrics = metrics;
|
||||
@@ -35,6 +37,7 @@ namespace PluralKit.Bot
|
||||
_switches = switches;
|
||||
_messages = messages;
|
||||
_webhookCache = webhookCache;
|
||||
_countHolder = countHolder;
|
||||
_logger = logger.ForContext<PeriodicStatCollector>();
|
||||
}
|
||||
|
||||
@@ -75,6 +78,9 @@ namespace PluralKit.Bot
|
||||
_metrics.Measure.Gauge.SetValue(CoreMetrics.ProcessHandles, process.HandleCount);
|
||||
_metrics.Measure.Gauge.SetValue(CoreMetrics.CpuUsage, await EstimateCpuUsage());
|
||||
|
||||
// Database info
|
||||
_metrics.Measure.Gauge.SetValue(CoreMetrics.DatabaseConnections, _countHolder.ConnectionCount);
|
||||
|
||||
// Other shiz
|
||||
_metrics.Measure.Gauge.SetValue(BotMetrics.WebhookCacheSize, _webhookCache.CacheSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user