-
Let's assume that, in a middleware we're generating a trace ID for the current request and we want all subsequent usages for this particular request to emit that trace ID. The trace ID is of course meant to be tied to a single request and not shared across requests. So in our middleware, we currently do this: sentry.ConfigureScope(func(scope *sentry.Scope) {
scope.SetTag("trace_id", traceID)
}) Is this intended usage? Will this Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Yes, because you're calling the "global" To isolate your additional data (in your case - provided by Are you using any specific framework?
In a general case, one should do something similar to this inside the request handler: if hub := sentry.GetHubFromContext(ctx); hub != nil {
hub.scope.SetTag("trace_id", traceID)
} ...also making sure that you have a |
Beta Was this translation helpful? Give feedback.
-
We're using go-chi and we do use the Lines 86 to 87 in f39baef Then in our code, we do use
hub := sentry.GetHubFromContext(ctx)
hub.ConfigureScope(...) // to set the trace_id tag and this would work as expected, i.e. it would be isolated between requests, since the hub is also isolated between each request. Is that correct? |
Beta Was this translation helpful? Give feedback.
-
Looks correct, yes. By the way, if you haven't seen it yet, here's another doc page we have on concurrency and hubs, hope it can further clarify the topic: https://docs.sentry.io/platforms/go/concurrency/ |
Beta Was this translation helpful? Give feedback.
Looks correct, yes.
By the way, if you haven't seen it yet, here's another doc page we have on concurrency and hubs, hope it can further clarify the topic: https://docs.sentry.io/platforms/go/concurrency/