-
-
Save up1/ab7d7cadcca1f8cff4a6803754927d15 to your computer and use it in GitHub Desktop.
Go Tracing + OpenTelemetry
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
func producer(ctx context.Context) { | |
tr := global.TraceProvider().Tracer("component-producer") | |
_, span := tr.Start(ctx, "producer") | |
defer span.End() | |
// Get tracing id and Parent span id | |
traceId := fmt.Sprintf("%016x", span.SpanContext().TraceID) | |
spanId := fmt.Sprintf("%016x", span.SpanContext().SpanID) | |
// Add to message | |
} |
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
func consumer(traceID string, spanID string) { | |
fn := initTracer("trace-consumer") | |
defer fn() | |
tid, _ := core.TraceIDFromHex(traceID) | |
sid, _ := core.SpanIDFromHex(spanID) | |
ctx := context.Background() | |
tr := global.TraceProvider().Tracer("consumer-step01") | |
sc := core.SpanContext{ | |
TraceID: tid, | |
SpanID: sid, | |
TraceFlags: 0x0, | |
} | |
_, span := tr.Start(trace.ContextWithRemoteSpanContext(ctx, sc), "consumer-span1") | |
span.End() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment