Skip to content

How to set tag on a transaction? #11028

@jeengbe

Description

@jeengbe

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.106.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

a

Expected Result

Formless issue; I am genually confused about traces/transactions/spans.
I thought I understood how all goes together (a trace is a collection of transactions, a transaction is a collection of spans, scopes are pushed and popped within a transaction and enrich events generated within them), but recent deprecations have left me wondering.

I want to set a tag on a transaction ("cache.hit"), and it all seems pretty straightforward with Sentry.getActiveTransaction()?.setTag('cache.hit', true);, both methods now deprecated. So Sentry.getActiveSpan()?.setAttribute('cache.hit', true). This, however, ends up settings the tag as an attribute, and only on the very span the tag was set in.


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 Sentry.startSpan(() => { ... }), two transactions end up in the same trace. The only top-level "trace" method is Sentry.continueTrace, but that doesn't sound right.

Actual Result

a

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nodeIssues related to the Sentry Node SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions