[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 <grufwub@gmail.com>
This commit is contained in:
Daenney
2023-02-17 12:02:29 +01:00
committed by GitHub
parent b5993095fa
commit 68e6d08c76
118 changed files with 813 additions and 591 deletions

View File

@@ -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
}
}