We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I want to inject Trace information in my logs ,
To this I added the following code to my application, with this code I do not see the trace information printed as the SpanCtx is not valid.
I ideally I would like to call trace.SpanContextFromContext. to get the Span Context for the (global) Tracer
trace.SpanContextFromContext
And use that to retrieve the current span/trace information
This might also be useful for adding span attributes
package main import ( "github.com/sirupsen/logrus" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" ) func main() { ctx := context.TODO() ctx, span := otel.Tracer("github.com/my/repo").Start(ctx, "log info") defer span.End() spanCtx := trace.SpanContextFromContext(ctx) logrus.WithFields(LogrusFields(spanCtx)).Info("loaded users") } func LogrusFields(spanCtx trace.SpanContext) logrus.Fields { if !spanCtx.IsValid() { return logrus.Fields{} } return logrus.Fields{ "span_id": spanCtx.SpanID().String(), "trace_id": spanCtx.TraceID().String(), "trace_flags": spanCtx.TraceFlags().String(), } }
The text was updated successfully, but these errors were encountered:
RonFed
Successfully merging a pull request may close this issue.
I want to inject Trace information in my logs ,
To this I added the following code to my application, with this code I do not see the trace information printed as the SpanCtx is not valid.
I ideally I would like to call
trace.SpanContextFromContext
. to get the Span Context for the (global) TracerAnd use that to retrieve the current span/trace information
This might also be useful for adding span attributes
The text was updated successfully, but these errors were encountered: