Skip to content

Commit 49984eb

Browse files
committed
fix tracing injection docs
1 parent 1f9e14f commit 49984eb

File tree

1 file changed

+5
-3
lines changed
  • platform-includes/distributed-tracing/custom-instrumentation

1 file changed

+5
-3
lines changed

platform-includes/distributed-tracing/custom-instrumentation/go.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ For distributed tracing to work, the two headers `sentry-trace` and `baggage`, m
2727
You can generate this tracing information with the Sentry SDK's `hub.GetTraceparent()` and `hub.GetBaggage()` functions. Here's an example using Guzzle:
2828

2929
```go
30-
hub := sentry.CurrentHub()
30+
// get the request context
31+
ctx := r.Context()
32+
hub := sentry.GetHubFromContext(ctx)
3133
req, _ := http.NewRequest("GET", "http://exmaple.com", nil)
32-
req.Header.Add(sentry.SentryTraceHeader, hub.GetTraceparent())
33-
req.Header.Add(sentry.SentryBaggageHeader, hub.GetBaggage())
34+
req.Header.Set(sentry.SentryTraceHeader, hub.GetTraceparent())
35+
req.Header.Set(sentry.SentryBaggageHeader, hub.GetBaggage())
3436
```
3537

3638
In this example, tracing information is propagated to the project running at `https://example.com`. If this project uses a Sentry SDK, it will extract and save the tracing information for later use.

0 commit comments

Comments
 (0)