Repository navigation
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which package are you using?
@sentry/node
SDK Version
7.12.1
Framework Version
express 4.18.1
Link to Sentry event
No response
Steps to Reproduce
I have a API created with express, and I want to integrate sentry into this so I can make performance checks for routes (how often are routes called, what is the request, what is the response) and I thought of using Sentry for that.
Right now my Sentry instance (Sentry 22.9.0.dev0 724ecd2) runs locally via Docker.
I am trying to integrate Sentry like this:
import express from 'express';
import * as bodyParser from 'body-parser';
import * as Sentry from "@sentry/node";
import "@sentry/tracing";
import {Integrations} from "@sentry/tracing";
import * as SentryUtils from '@sentry/utils';
import { RewriteFrames } from "@sentry/integrations";
const app = App.expressInstance; //express.Application
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.ENV,
debug: true,
attachStacktrace: true,
beforeSend(event) {
console.log(event);
return event;
},
integrations: [
new RewriteFrames({
root: process.cwd(),
}),
new Sentry.Integrations.Http({ tracing: true, breadcrumbs: true }),
new Integrations.Express({
app,
}),
],
tracesSampleRate: 1.0,
});
App.expressInstance.use(Sentry.Handlers.requestHandler() as express.RequestHandler);
App.expressInstance.use(Sentry.Handlers.tracingHandler());
console.log("Sentry enabled");
I can see debugging logs like this in my console:
App listening on the port 5000
Sentry Logger [log]: [Tracing] starting http.server transaction - POST /cart
Sentry Logger [log]: [Tracing] Starting 'express.middleware.use' span on transaction 'POST /cart' (82ce398e82749a13).
Sentry Logger [log]: [Tracing] Finishing 'express.middleware.use' span on transaction 'POST /cart' (82ce398e82749a13).
Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'POST /cart' (82ce398e82749a13).
Sentry Logger [log]: [Tracing] Adding sentry-trace header 12fddcbf9f5141279de11c25c337ea4a-a8eb4b81bbd54870-1 to outgoing request to "https://snip":
Sentry Logger [log]: [Tracing] Finishing 'http.client' span on transaction 'POST /cart' (82ce398e82749a13).
Sentry Logger [log]: [Tracing] Finishing http.server transaction: POST /cart.
However I have no events of it in my Sentry WebUI.
How can I check if requests (to Sentry) actually get sent?
Expected Result
See any results in Sentry WebUI > Performance
Actual Result
No results in Sentry WebUI > Performance
Metadata
Metadata
Assignees
Labels
No labels
Activity
pquerner commentedon Sep 5, 2022
Having a verify transaction like this (like recommended from the Docs) used to show this transaction in the Sentry WebUI.
It did this morning. Running the code again, does not produce it anymore. (Might be something because I tinkered with the
initcall)pquerner commentedon Sep 6, 2022
Fixed it. I had some other app listening on the same port (9000) and therefore no issues/reports got sent.
Still, can this behaviour be reported back to the developer somehow?
AbhiPrasad commentedon Sep 6, 2022
Hey - glad to see you sorted out the issue. Is there something in particular you'd like to see reported back (any kind of specific info)?