From cfd9dff6c5ede69fe7a74f06997c0c4ce377d90d Mon Sep 17 00:00:00 2001 From: spiral Date: Tue, 21 Jun 2022 11:11:47 -0400 Subject: [PATCH] feat(bot): tag cluster ID in sentry events --- PluralKit.Bot/Utils/SentryUtils.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/Utils/SentryUtils.cs b/PluralKit.Bot/Utils/SentryUtils.cs index 97471821..9e715387 100644 --- a/PluralKit.Bot/Utils/SentryUtils.cs +++ b/PluralKit.Bot/Utils/SentryUtils.cs @@ -17,10 +17,12 @@ public class SentryEnricher: ISentryEnricher { private readonly Bot _bot; + private readonly BotConfig _config; - public SentryEnricher(Bot bot) + public SentryEnricher(Bot bot, BotConfig config) { _bot = bot; + _config = config; } // TODO: should this class take the Scope by dependency injection instead? @@ -37,6 +39,8 @@ public class SentryEnricher: {"message", evt.Id.ToString()} }); scope.SetTag("shard", shardId.ToString()); + if (_config.Cluster != null) + scope.SetTag("cluster", _config.Cluster!.NodeIndex.ToString()); // Also report information about the bot's permissions in the channel // We get a lot of permission errors so this'll be useful for determining problems @@ -56,6 +60,8 @@ public class SentryEnricher: {"messages", string.Join(",", evt.Ids)} }); scope.SetTag("shard", shardId.ToString()); + if (_config.Cluster != null) + scope.SetTag("cluster", _config.Cluster!.NodeIndex.ToString()); } public void Enrich(Scope scope, int shardId, MessageUpdateEvent evt) @@ -68,6 +74,8 @@ public class SentryEnricher: {"message", evt.Id.ToString()} }); scope.SetTag("shard", shardId.ToString()); + if (_config.Cluster != null) + scope.SetTag("cluster", _config.Cluster!.NodeIndex.ToString()); } public void Enrich(Scope scope, int shardId, MessageDeleteEvent evt) @@ -80,6 +88,8 @@ public class SentryEnricher: {"message", evt.Id.ToString()} }); scope.SetTag("shard", shardId.ToString()); + if (_config.Cluster != null) + scope.SetTag("cluster", _config.Cluster!.NodeIndex.ToString()); } public void Enrich(Scope scope, int shardId, MessageReactionAddEvent evt) @@ -94,5 +104,7 @@ public class SentryEnricher: {"reaction", evt.Emoji.Name} }); scope.SetTag("shard", shardId.ToString()); + if (_config.Cluster != null) + scope.SetTag("cluster", _config.Cluster!.NodeIndex.ToString()); } } \ No newline at end of file