Skip to content

Commit

Permalink
fix example context
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua MacDonald committed Jun 22, 2021
1 parent 702edaf commit b277217
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/tracing/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import (
)

func main() {

attributes := map[string]string{
"book.condition": "good",
"book.category": "science",
}

lsLauncher := launcher.ConfigureOpentelemetry(
// example for setting resource attributes:
launcher.WithResourceAttributes(attributes),
)
defer lsLauncher.Shutdown()
Expand Down Expand Up @@ -64,7 +64,7 @@ func main() {
// example of getting the current span
func getSpan(ctx context.Context) {
span := trace.SpanFromContext(ctx)
fmt.Printf("current span: %v\n", span)
fmt.Printf("current span: %v\n", span.SpanContext().SpanID())
}

// example of adding an attribute to a span
Expand Down Expand Up @@ -93,7 +93,7 @@ func recordException(ctx context.Context) {
func createChild(ctx context.Context, tracer trace.Tracer) {
_, childSpan := tracer.Start(ctx, "child")
defer childSpan.End()
fmt.Printf("child span: %v\n", childSpan)
fmt.Printf("child span: %v\n", childSpan.SpanContext().SpanID())
}

// example of setting baggage
Expand All @@ -102,5 +102,5 @@ func setBaggage(ctx context.Context) context.Context {
mem2, _ := baggage.NewMember("keytwo", "bar1")
bag, _ := baggage.New(mem1, mem2)

return baggage.ContextWithBaggage(context.Background(), bag)
return baggage.ContextWithBaggage(ctx, bag)
}

0 comments on commit b277217

Please sign in to comment.