-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
-
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
Beta Was this translation helpful? Give feedback.
All reactions
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?
Replies: 3 comments 4 replies
-
const transaction = Sentry.startTransaction({
op: "test",
name: "My First Test Transaction",
});
setTimeout(() => {
try {
foo();
} catch (e) {
Sentry.captureException(e);
} finally {
transaction.finish();
}
}, 99);
Having a verify transaction like this (like recommended from the Docs) used to show this transaction in the Sentry WebUI.
Screenshot 2022年09月05日 at 17 45 35
It did this morning. Running the code again, does not produce it anymore. (Might be something because I tinkered with the init call)
Beta Was this translation helpful? Give feedback.
All reactions
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
-
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)?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey!
I do not have logs on my hands right now, but I had trouble (re)starting the docker enviroment of Sentry.
When I had this, and triggered something from my Node App, a message a like "could not connect to ::9134" was added to stderr (from console.error ?).
So something like this - but when the Sentry Backend is fully operational.
"Wanted to send event to sentry backend, but could not reach it at xxxx" ?
Beta Was this translation helpful? Give feedback.
All reactions
-
We do log this out in the debug logs here:
Beta Was this translation helpful? Give feedback.
All reactions
-
No it did not show up.
> node --es-module-specifier-resolution=node .
(node:29175) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: RewriteFrames
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: Express
Sentry enabled
App listening on the port 5000
Sentry Logger [log]: [Tracing] starting http.server transaction - POST /cart/add/product/61
Sentry Logger [log]: [Tracing] Starting 'express.middleware.use' span on transaction 'POST /cart/add/product/61' (a5acd40853ee02ab).
Sentry Logger [log]: [Tracing] Finishing 'express.middleware.use' span on transaction 'POST /cart/add/product/61' (a5acd40853ee02ab).
Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'POST /cart/add/product/:productId' (a5acd40853ee02ab).
Sentry Logger [log]: [Tracing] Adding sentry-trace header 3c07496c6862433198151680b3a73107-9de93537f69e1a9e-1 to outgoing request to "https://snip":
Sentry Logger [log]: [Tracing] Finishing 'http.client' span on transaction 'POST /cart/add/product/:productId' (a5acd40853ee02ab).
Sentry Logger [log]: [Tracing] Finishing http.server transaction: POST /cart/add/product/:productId.
Sentry Logger [log]: [Tracing] starting http.server transaction - POST /cart/add/product/61
Sentry Logger [log]: [Tracing] Starting 'express.middleware.use' span on transaction 'POST /cart/add/product/61' (a6edd1770868d4a7).
Sentry Logger [log]: [Tracing] Finishing 'express.middleware.use' span on transaction 'POST /cart/add/product/61' (a6edd1770868d4a7).
Sentry Logger [log]: [Tracing] Starting 'http.client' span on transaction 'POST /cart/add/product/:productId' (a6edd1770868d4a7).
Sentry Logger [log]: [Tracing] Adding sentry-trace header 90fd0d40b06546e7960fd2d03587b2a2-bbe663b9a8b010a7-1 to outgoing request to "https://snip":
Sentry Logger [log]: [Tracing] Finishing 'http.client' span on transaction 'POST /cart/add/product/:productId' (a6edd1770868d4a7).
Sentry Logger [log]: [Tracing] Finishing http.server transaction: POST /cart/add/product/:productId.
Beta Was this translation helpful? Give feedback.
All reactions
-
That's strange - I wonder why it's happening. Maybe something is failing silently before then?
Beta Was this translation helpful? Give feedback.