From 6b6530d3f0e625c724bea39da9617dee12328005 Mon Sep 17 00:00:00 2001 From: dblinkhorn Date: Tue, 11 Aug 2026 10:02:03 -0700 Subject: [PATCH] feat: make github request ID logging opt-in --- githubapp/middleware_logging.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/githubapp/middleware_logging.go b/githubapp/middleware_logging.go index 79a9c163..46b40e58 100644 --- a/githubapp/middleware_logging.go +++ b/githubapp/middleware_logging.go @@ -74,7 +74,7 @@ func ClientLogging(lvl zerolog.Level, opts ...ClientLoggingOption) ClientMiddlew cached := res.Header.Get(httpcache.XFromCache) != "" evt.Bool("cached", cached). Int("status", res.StatusCode) - if requestID := res.Header.Get(httpHeaderRequestID); requestID != "" { + if requestID := res.Header.Get(httpHeaderRequestID); options.LogGitHubRequestID && requestID != "" { evt.Str("github_request_id", requestID) } @@ -113,6 +113,7 @@ type clientLoggingOptions struct { // Output control LogRateLimitInformation *RateLimitLoggingOption + LogGitHubRequestID bool } // RateLimitLoggingOption controls which rate limit information is logged. @@ -152,6 +153,13 @@ func LogRateLimitInformation(options *RateLimitLoggingOption) ClientLoggingOptio } } +// LogGitHubRequestID enables logging of the request ID returned by GitHub. +func LogGitHubRequestID() ClientLoggingOption { + return func(opts *clientLoggingOptions) { + opts.LogGitHubRequestID = true + } +} + func mirrorRequestBody(r *http.Request) (*http.Request, []byte, error) { switch { case r.Body == nil || r.Body == http.NoBody: