From 68e6d08c768b789987a753d42f66caf73ce10ee1 Mon Sep 17 00:00:00 2001 From: Daenney Date: Fri, 17 Feb 2023 12:02:29 +0100 Subject: [feature] Add a request ID and include it in logs (#1476) This adds a lightweight form of tracing to GTS. Each incoming request is assigned a Request ID which we then pass on and log in all our log lines. Any function that gets called downstream from an HTTP handler should now emit a requestID=value pair whenever it logs something. Co-authored-by: kim --- internal/typeutils/astointernal.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/typeutils/astointernal.go') diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go index fff9c807a..2ed1d52d3 100644 --- a/internal/typeutils/astointernal.go +++ b/internal/typeutils/astointernal.go @@ -82,7 +82,7 @@ func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable a // account emojis (used in bio, display name, fields) if emojis, err := ap.ExtractEmojis(accountable); err != nil { - log.Infof("ASRepresentationToAccount: error extracting account emojis: %s", err) + log.Infof(nil, "error extracting account emojis: %s", err) } else { acct.Emojis = emojis } @@ -217,13 +217,13 @@ func (c *converter) extractAttachments(i ap.WithAttachment) []*gtsmodel.MediaAtt attachmentable, ok := t.(ap.Attachmentable) if !ok { - log.Error("ap attachment was not attachmentable") + log.Error(nil, "ap attachment was not attachmentable") continue } attachment, err := ap.ExtractAttachment(attachmentable) if err != nil { - log.Errorf("error extracting attachment: %s", err) + log.Errorf(nil, "error extracting attachment: %s", err) continue } @@ -684,7 +684,7 @@ func (c *converter) ASFlagToReport(ctx context.Context, flaggable ap.Flaggable) return nil, fmt.Errorf("ASFlagToReport: db error getting status with url %s: %w", statusURIString, err) } - log.Warnf("ASFlagToReport: reported status %s could not be found in the db, skipping it", statusURIString) + log.Warnf(nil, "reported status %s could not be found in the db, skipping it", statusURIString) continue } } -- cgit v1.2.3