-
Notifications
You must be signed in to change notification settings - Fork 22
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
Have you considered writing the trace ID back to the response header? #23
Comments
Adding a middleware should meet your needs. package middleware
import (
"context"
"github.com/cloudwego/hertz/pkg/app"
oteltrace "go.opentelemetry.io/otel/trace"
)
func TraceMiddleware() app.HandlerFunc {
return func(ctx context.Context, c *app.RequestContext) {
c.Next(ctx)
c.Header("trace-id", oteltrace.SpanFromContext(ctx).SpanContext().TraceID().String())
}
} |
Yes, it's possible to add a middleware to fulfill this requirement. Raising this issue is to inquire whether there has been consideration to add this functionality to the project. |
I will take a look later, and if you can submit a PR, will greatly appreciate it. |
Sure, I will submit a pull request. When the time comes, could you please review it? |
Of course, thank you very much. |
During the debugging process, it may be necessary to use the trace ID to troubleshoot issues. As a server-side developer, I would appreciate it if others could provide me with the trace ID of the problematic requests.
The text was updated successfully, but these errors were encountered: