Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions githubapp/middleware_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
httpHeaderRateUsed = "X-Ratelimit-Used"
httpHeaderRateReset = "X-Ratelimit-Reset"
httpHeaderRateResource = "X-Ratelimit-Resource"
httpHeaderRequestID = "X-GitHub-Request-Id"
)

// ClientLogging creates client middleware that logs request and response
Expand Down Expand Up @@ -73,6 +74,9 @@ 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 != "" {
evt.Str("github_request_id", requestID)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its probably friendly to always log this, but that being said similar to logging the rate limit info we may want to gate this info in an option to allow users who are sensitive to log volume to opt in or out. I'm happy to merge as is though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion @asvoboda. Created a follow-up PR to address this.


size := res.ContentLength
if requestMatches(r, options.ResponseBodyPatterns) {
Expand Down