Last active
March 8, 2024 18:48
-
-
Save benhenryhunter/9e2c8f7b89f67950fa5f15f630e9d566 to your computer and use it in GitHub Desktop.
example of the parent, child, and sibling tracing structure
This file contains 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 TraceExample(rootContext context.Context) { | |
parentSpan := trace.SpanFromContext(rootContext) | |
rootContextWithParentSpan = trace.ContextWithSpan(context.Background(), parentSpan) | |
traceFunctionContext, traceFunctionSpan := s.tracer.Start(rootContextWithParentSpan, "traceFunction") | |
childContext, childSpan := s.tracer.Start(traceFunctionContext, "childTrace") | |
_, grandchildSpan := s.tracer.Start(childContext, "grandchildTrace") | |
grandchildSpan.End() | |
childSpan.End() | |
siblingContext, siblingSpan := s.tracer.Start(rootContextWithParentSpan, "siblingTrace") | |
_, siblingChildSpan := s.tracer.Start(siblingContext, "siblingChildTrace") | |
siblingChildSpan.End() | |
siblingSpan.End() | |
parentSpan.End() | |
} | |
// heirarchical tracing | |
// ^ parent | |
// ^ child | |
// ^ grandchild | |
// ^ sibling |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment