-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add request id to logs. #4461
base: main
Are you sure you want to change the base?
Add request id to logs. #4461
Conversation
ae9344f
to
48f0ceb
Compare
cmd/cli/app/history/history_list.go
Outdated
fmt.Printf("%+v\n", rID) | ||
fmt.Printf("%+v\n", header) | ||
fmt.Printf("%+v\n", trailer) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This obviously needs to be reverted, but I'm wondering what would be the right way to output the request id in the CLI.
71d4a69
to
9d1d981
Compare
9d1d981
to
8079246
Compare
func maybeGetRequestID(ctx context.Context) string { | ||
var rID string | ||
if md, ok := metadata.FromIncomingContext(ctx); ok { | ||
if rIDs, ok := md["request-id"]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in HTTP what would this translate to? I wonder how it works with the HTTP gateway we use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GRPC moves back and forth headers having prefix Grpc-Metadata-
, so it would become Grpc-Metadata-Request-Id
.
We might want to use https://www.w3.org/TR/trace-context/ or https://uptrace.dev/opentelemetry/opentelemetry-traceparent.html |
8079246
to
8111143
Compare
@evankanderson while estimating work to improve logging I had a look at the documents you linked. My take is that the capabilities described in those specs far exceed our current need, which is to track a request execution from start to finish in logs. My take is that we're better off polishing this work, possibly changing the header's key (not the value), and merge it. |
Sounds good; I'd thought this would be something like: import "go.opentelemetry.io/otel/trace"
// ...
sc := trace.SpanContextFromContext(ctx)
ctx = zerolog.Ctx(ctx).With().Str("trace_id", sc.TraceID()).Logger().WithContext(ctx) If there's a bunch more content, then I'd agree on doing our own thing. |
This change adds a GRPC interceptor that fetches the header `Grpc-Metadata-Request-Id` and adds it to the logger. It also returns the request id to the client in the trailer, which is helpful for debugging. CLI command `minder history list` was modified to show its usage, but those changes should be reverted.
8111143
to
4c55b9b
Compare
Summary
This change adds a GRPC interceptor that fetches the header
Grpc-Metadata-Request-Id
and adds it to the logger. It also returns the request id to the client in the trailer, which is helpful for debugging.CLI command
minder history list
was modified to show its usage, but those changes should be reverted.Change Type
Testing
Manual tests.
Review Checklist: