From d708525a2f59711599311782d1c663e7f4f65441 Mon Sep 17 00:00:00 2001 From: Daan Boerlage Date: Fri, 17 Sep 2021 14:07:19 +0200 Subject: [PATCH] Add traces to the !quote command --- src/Bot/Commands/Utils/Quote/Quote.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Bot/Commands/Utils/Quote/Quote.cs b/src/Bot/Commands/Utils/Quote/Quote.cs index e79663c..fdf1030 100644 --- a/src/Bot/Commands/Utils/Quote/Quote.cs +++ b/src/Bot/Commands/Utils/Quote/Quote.cs @@ -15,6 +15,8 @@ using Geekbot.Core.Polyfills; using Geekbot.Core.RandomNumberGenerator; using Geekbot.Core.UserRepository; using Microsoft.EntityFrameworkCore; +using Sentry; +using Constants = Geekbot.Core.Constants; namespace Geekbot.Bot.Commands.Utils.Quote { @@ -43,23 +45,32 @@ namespace Geekbot.Bot.Commands.Utils.Quote { try { + var getTotalSpan = Transaction.StartChild("TotalQuotes"); var totalQuotes = await _database.Quotes.CountAsync(e => e.GuildId.Equals(Context.Guild.Id.AsLong())); + getTotalSpan.Finish(); if (totalQuotes == 0) { await ReplyAsync(Localization.Quote.NoQuotesFound); + Transaction.Status = SpanStatus.NotFound; return; } + var getQuoteFromDbSpan = Transaction.StartChild("GetQuoteFromDB"); var random = _randomNumberGenerator.Next(0, totalQuotes - 1); var quote = _database.Quotes.Where(e => e.GuildId.Equals(Context.Guild.Id.AsLong())).Skip(random).Take(1); + getQuoteFromDbSpan.Finish(); + var replySpan = Transaction.StartChild("Reply"); var embed = QuoteBuilder(quote.FirstOrDefault()); await ReplyAsync("", false, embed.Build()); + replySpan.Finish(); + Transaction.Status = SpanStatus.Ok; } catch (Exception e) { await ErrorHandler.HandleCommandException(e, Context, "Whoops, seems like the quote was to edgy to return"); + Transaction.Status = SpanStatus.InternalError; } }