Repository navigation
Conversation
newHTTPLogger discarded the zerolog.Context returned by ctx.Str and ctx.Bool. zerolog.Context methods have value receivers and return the updated context, so the cfRay and lbProbe fields were never added to the per-request logger. Since TUN-8238 (2024.2.1), origin request error lines and the debug request/response lines carry no Ray ID, so they can't be correlated with Cloudflare edge logs or origin access logs. Assign the returned context, and add a test covering the Cf-Ray, load balancer probe and plain request cases. Fixes cloudflare#1756
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
newHTTPLoggerbuilds the logger used for every proxied HTTP request, but it discards thezerolog.Contextreturned byctx.Str(logFieldCFRay, ...)andctx.Bool(logFieldLBProbe, ...).zerolog.Contextmethods have value receivers and return the updated context, socfRayandlbProbehave been missing from these log lines since TUN-8238 (971360d, first released in 2024.2.1).As a result, origin request error lines and the debug request/response lines carry no Ray ID, so they can't be correlated with Cloudflare edge logs (Logpush
RayID) or with origin access logs that record theCf-Rayheader.Fix
Assign the returned context:
This restores fields
newHTTPLoggerwas already meant to emit. No new log fields, and no change to log levels or messages.Test plan
TestNewHTTPLoggerContextFields(request withCf-Ray, load balancer probe, plain request). It fails onmaster(cfRayandlbProbemissing) and passes with this change.go test -race ./proxy/...go vet ./proxy/,gofmt -l,goimports -local github.com/cloudflare/cloudflaredgolangci-lint run ./proxy/...(v2.14.0, repo config): 0 issuesFixes #1756