Thanks Nick, that looks like it does the trick.
I did have some questions about the Hubs/Scopes. Our backend processes multiple concurrent requests, which seem to get jumbled up in Sentry.
For example, we may have these endpoints:
Endpoint A: Queries the DB, then hits an external API and returns some value.
Endpoint B: Queries the DB and returns some value.
If Endpoint B’s Db query is executed between the DB query and external API call of Endpoint A, what seems to happen is that once the Endpoint A transaction finishes, the scope had been changed by Endpoint B and therefore the event in Sentry is incorrect.
The pseudocode flow is:
- On request, extract request ID, path, method and store in a map (with ID as the key). Attach the transaction to the current scope.
- Before response, set the status code of the transaction and finish it.
Is there a way for us to generate and destroy isolated scopes/hubs dynamically? Or is there some other way for us to handle this use case