Skip to content

Still have express is not instrumented. error #15159

@webPlayer7

Description

@webPlayer7

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

8.51.0

Framework Version

Express v5

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from '@sentry/node'


Sentry.init({
    dsn: process.env.SENTRY_DSN,
    environment: process.env.SENTRY_ENVIRONMENT,
    release: appVersion,
    tracesSampleRate: 0.0,
})

console.log(`================================`)
console.log(`****** Sentry Initialized ******`)
console.log('================================')

export { Sentry }

Above is my sentry instrument js and I import that file in the index.js like below
import { Sentry } from './instrument.js'

I confirmed it gets the correct env values. My express version is v5. And I use esm mode to import so I run this command to import instrument.js
nodemon --import ./build/instrument.js build/index.js

When I use express v4, it worked but after migrate it shows sentry warning again

[1] [Sentry] express is not instrumented. Please make sure to initialize Sentry in a separate file that you --import when running node, see: https://docs.sentry.io/platforms/javascript/guides/express/install/esm/.

Steps to Reproduce

  1. Sentry init in instrument.js
  2. Import instrument.js in index.js
  3. Run script in esm mode , use --import flag to import

Expected Result

There should no sentry warning

Actual Result

[1] [Sentry] express is not instrumented. Please make sure to initialize Sentry in a separate file that you --import when running node, see: https://docs.sentry.io/platforms/javascript/guides/express/install/esm/.

There is sentry warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nodeIssues related to the Sentry Node SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions