Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate auto-instrumented spans in traces #15803

Open
3 tasks done
serglom21 opened this issue Mar 24, 2025 · 2 comments
Open
3 tasks done

Duplicate auto-instrumented spans in traces #15803

serglom21 opened this issue Mar 24, 2025 · 2 comments
Labels
Package: node Issues related to the Sentry Node SDK Waiting for: Community

Comments

@serglom21
Copy link

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.1.0

Framework Version

Express 4.21.2

Link to Sentry event

No response

Reproduction Example/SDK Setup

Sentry.init({
    enabled: environment !== 'local' || process.env.SENTRY_ENABLED?.toLowerCase() === 'true',
    environment,
    dsn: process.env.SENTRY_DSN,
    // Mark the release, this will help us pinpoint the source of issues
    release: process.env.SHORT_SHA,
    debug: process.env.SENTRY_DEBUG?.toLowerCase() === 'true',
    tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE ?? 0.01),
    profilesSampleRate: Number(process.env.SENTRY_PROFILES_SAMPLE_RATE ?? 0.01),
    normalizeDepth: 10,
    initialScope: {
        tags: {
            location: process.env.LOCATION ?? 'unknown',
            container_name: process.env.CONTAINER_NAME ?? 'unknown',
        },
    },
    integrations: [Sentry.prismaIntegration(), nodeProfilingIntegration()],
    beforeBreadcrumb: (breadcrumb, _) => {
        if (breadcrumb.category === 'http') {
            // Ignore spans/breadcrumbs calling apm
            const url = breadcrumb.data?.url;
            if (url?.includes('.split.io/') || url?.includes('ingest.sentry.io/')) {
                return null;
            }
        }
        return breadcrumb;
    },
    beforeSendTransaction: (event, _) => {
        // redact x-access-token from transactions
        if (event.request?.headers && event.request?.headers['x-access-token']) {
            event.request.headers['x-access-token'] = 'REDACTED';
        }
        return event;
    },
    ignoreTransactions: [/GET \/_health/, /GET \/_ready/, /GET \/_startup/, /OPTIONS \//],
});

Steps to Reproduce

  1. Capture traces with sentry.javascript.node@9.1.0.
  2. Look at thehttp.serverspans
  3. Note the presence of two spans for the same endpoint within the same trace.
  4. Compare the two spans:
    • The first span lacks child middleware spans (no expandable '+' indicator).
    • The second span includes child middleware spans.
    • The second span contains additional custom tags absent in the first span.

Expected Result

  • Each unique operation (span) should be recorded only once per trace.
  • All relevant context and middleware information should be consistently captured within a single span.

Actual Result

Duplicate spans for the same HTTP operation

More information on internal customer case

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 24, 2025
@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Mar 24, 2025
@lforst
Copy link
Member

lforst commented Mar 25, 2025

The only possible explanation I have for this is that Sentry.init() is called more than once, or that multiple clients are initialized and instrumenting http with the httpIntegration

@s1gr1d
Copy link
Member

s1gr1d commented Mar 25, 2025

I just tested it in a small reproduction and used the provided options in the Sentry.init(), the same express and Sentry version. Sadly, I cannot reproduce the issue.

In the linked doc, I see that the endpoints are triggered by a frontend. Does the same happen if you curl the endpoint directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: node Issues related to the Sentry Node SDK Waiting for: Community
Projects
Status: Waiting for: Community
Development

No branches or pull requests

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy