-
I am genually confused about traces/transactions/spans. I want to set a tag on a transaction ("cache.hit"), and it all seems pretty straightforward with Also, unrelated to above, how do I prevent two separate transactions (minutes apart) from using the same trace ID? When a koa request comes in, I run the handler within |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Thanks, forgot discussions exist. 😅 |
Beta Was this translation helpful? Give feedback.
-
If you really want to exclusively set a tag on a transaction you can do the following: const activeSpan = Sentry.getActiveSpan();
if (activeSpan) {
Sentry.getRootSpan(activeSpan).setAttribute('foo', 'bar');
} More easily though, if you're ok with the tag also being set on other events on the same request, you can just do As for your second question, that sounds a bit shit. In my humble opinion
Does that sort of help? We are aiming to fix all of this in the next major version btw. We fully acknowledge that the current api is crap. |
Beta Was this translation helpful? Give feedback.
-
@lforst Based on your above comment, does that mean that a transaction is not a collection of spans, but instead, the root span itself? |
Beta Was this translation helpful? Give feedback.
-
Lastly, how does |
Beta Was this translation helpful? Give feedback.
If you really want to exclusively set a tag on a transaction you can do the following:
More easily though, if you're ok with the tag also being set on other events on the same request, you can just do
Sentry.setTag('foo', 'bar')
. Note that this will require an active isolation scope, which is normally something we create automatically for you with an integration, but in the case of Koa you likely need to do this yourself, but it is pretty straight forward. Just wrap any execution context inSentry.withIsolationScope(() => { ... })
. The right place for this is usually…