Skip to content

@sentry/node creates duplicate Transactions #15830

Open
@enixsoft

Description

@enixsoft

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

9.9.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

// middleware

import * as Sentry from '@sentry/node'

const activeSpan = Sentry.getActiveSpan()
const rootSpan = activeSpan && Sentry.getRootSpan(activeSpan)

if (rootSpan) {
// ctx.routeKey is string, for example "GET-/users"
Sentry.updateSpanName(rootSpan, ctx.routeKey || 'unknown')
}

Steps to Reproduce

I am using AdonisJS v6 framework with the Sentry integration rlanz/sentry v0.3.3 and @sentry/node package v9.9.0.

In my reproduction example there is a code from middleware that runs on every request and it's supposed to update the root span (transaction) name. The root span is expected to always be http.server operation with origin auto.http.otel.http.

In my Sentry dashboard, I see transactions on the sampled events with the correct updated name, they contain spans and have user attached, but I also see events from another transaction which is using the automatically generated name, but always without any spans and without user. Those duplicate transactions are easy to notice because the names are similar, the events are traced at the same time with nearly the same duration. Also the data (like request query string, headers, cookies) is same in both, so I assume that it's a duplicated transaction from the exact same request.

There is also other difference I see comparing the JSON of both sampled events which might explain this, the transaction with updated name by middleware has sentry.source: custom and "transaction_info": { "source": "custom" } in its data. And the duplicate has sentry.source: url and "transaction_info": { "source": "sanitized" }.

Expected Result

Only one transaction (the one with updated name) will appear in Sentry dashboard for specific request.

Actual Result

Transactions seem to be duplicated.

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions