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

Typescript Express server tracing not working. tracingHandler need casting? How? #8364

Closed
3 tasks done
sunshineo opened this issue Jun 19, 2023 · 4 comments
Closed
3 tasks done
Labels
Package: node Issues related to the Sentry Node SDK Type: Bug

Comments

@sunshineo
Copy link

sunshineo commented Jun 19, 2023

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

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Sentry.init({
  dsn: "MY_DSN",
  integrations: [
    // enable HTTP calls tracing
    new Sentry.Integrations.Http({ tracing: true }),
    // enable Express.js middleware tracing
    new Sentry.Integrations.Express({ app }),
    // Automatically instrument Node.js libraries and frameworks
    ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
    environment: config.env,
    release: process.env.SENTRY_RELEASE || 'unknown',
  ],

  // Set tracesSampleRate to 1.0 to capture 100%
  // of transactions for performance monitoring.
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,
});
// RequestHandler creates a separate execution context, so that all
// transactions/spans/breadcrumbs are isolated across requests
app.use(Sentry.Handlers.requestHandler() as express.RequestHandler);
// TracingHandler creates a trace for every incoming request
app.use(Sentry.Handlers.tracingHandler());

//...

// The error handler must be before any other error middleware and after all controllers
app.use(Sentry.Handlers.errorHandler() as express.ErrorRequestHandler);

Steps to Reproduce

It was not working for me on capture errors until I find the documentation that I need to do casting for:

...
app.use(Sentry.Handlers.requestHandler() as express.RequestHandler);
//...
app.use(Sentry.Handlers.errorHandler() as express.ErrorRequestHandler);
//...

After that, I get errors. But tracing still does not work. Could it be because

app.use(Sentry.Handlers.tracingHandler());

Also need casting? How? I've tried

app.use(Sentry.Handlers.tracingHandler() as express.RequestHandler);
app.use(Sentry.Handlers.tracingHandler() as express.Handler);

Neither works.

Expected Result

Tracing to work

Actual Result

Tracing not working

@sunshineo sunshineo changed the title Typescript Express server tra Typescript Express server tracing not working. tracingHandler need casting? How? Jun 19, 2023
@lforst
Copy link
Member

lforst commented Jun 20, 2023

Hi, thanks for writing in! Can you share the versions of express and Typescript you're using? Thanks!

@lforst lforst added the Package: node Issues related to the Sentry Node SDK label Jun 20, 2023
@sunshineo
Copy link
Author

"@sentry/node": "^7.55.2",
"@types/express": "^4.17.17",
"express": "^4.17.1",
"typescript": "^5.0.4"

@lforst
Copy link
Member

lforst commented Jun 22, 2023

What are the exact errors you're getting?

@sunshineo
Copy link
Author

Turns out we ran out of quota 😄

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 Type: Bug
Projects
Archived in project
Development

No branches or pull requests

2 participants