fix: fix reporting Discord response metrics to influxdb
This commit is contained in:
parent
24a549341e
commit
48d4009c69
@ -209,8 +209,7 @@ namespace Myriad.Rest
|
||||
|
||||
await HandleApiError(response, ignoreNotFound);
|
||||
|
||||
if (OnResponseEvent != null)
|
||||
OnResponseEvent.Invoke(null, (
|
||||
OnResponseEvent?.Invoke(null, (
|
||||
GetEndpointMetricsName(response.RequestMessage!),
|
||||
(int)response.StatusCode,
|
||||
stopwatch.ElapsedTicks
|
||||
|
@ -19,7 +19,7 @@ namespace Myriad.Rest
|
||||
public DiscordApiClient(string token, ILogger logger, string? baseUrl = null)
|
||||
{
|
||||
_client = new BaseRestClient(UserAgent, token, logger, baseUrl ?? DefaultApiBaseUrl);
|
||||
_client.OnResponseEvent += OnResponseEvent;
|
||||
_client.OnResponseEvent += (_, ev) => OnResponseEvent?.Invoke(null, ev);
|
||||
}
|
||||
|
||||
public EventHandler<(string, int, long)> OnResponseEvent;
|
||||
|
@ -52,10 +52,12 @@ namespace PluralKit.Bot
|
||||
c.Resolve<BotConfig>().DiscordBaseUrl
|
||||
);
|
||||
|
||||
var metrics = c.Resolve<IMetrics>();
|
||||
|
||||
client.OnResponseEvent += ((_, ev) =>
|
||||
{
|
||||
var (endpoint, statusCode, ticks) = ev;
|
||||
var timer = c.Resolve<IMetrics>().Provider.Timer.Instance(BotMetrics.DiscordApiRequests, new MetricTags(
|
||||
var timer = metrics.Provider.Timer.Instance(BotMetrics.DiscordApiRequests, new MetricTags(
|
||||
new[] { "endpoint", "status_code" },
|
||||
new[] { endpoint, statusCode.ToString() }
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user