-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
request
not captured in @sentry/aws-serverless
+ express
#14239
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hey @relm923, thanks for reaching out. The latest docs on express can be found here. |
Hi @chargome removing import * as Sentry from '@sentry/aws-serverless';
Sentry.init({
debug: true,
dsn: process.env.SENTRY_DSN,
environment: 'development',
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
});
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: NodeFetch
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: LocalVariablesAsync
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: ProcessAndThreadBreadcrumbs
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: Aws
Sentry Logger [log]: Integration installed: AwsLambda
Sentry Logger [log]: Running in CommonJS mode. import * as Sentry from '@sentry/aws-serverless';
Sentry.init({
debug: true,
dsn: process.env.SENTRY_DSN,
environment: 'development',
integrations: [Sentry.expressIntegration()],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
});
Sentry Logger [log]: Integration installed: InboundFilters
Sentry Logger [log]: Integration installed: FunctionToString
Sentry Logger [log]: Integration installed: LinkedErrors
Sentry Logger [log]: Integration installed: RequestData
Sentry Logger [log]: Integration installed: Console
Sentry Logger [log]: Integration installed: Http
Sentry Logger [log]: Integration installed: NodeFetch
Sentry Logger [log]: Integration installed: OnUncaughtException
Sentry Logger [log]: Integration installed: OnUnhandledRejection
Sentry Logger [log]: Integration installed: ContextLines
Sentry Logger [log]: Integration installed: LocalVariablesAsync
Sentry Logger [log]: Integration installed: Context
Sentry Logger [log]: Integration installed: ProcessAndThreadBreadcrumbs
Sentry Logger [log]: Integration installed: Modules
Sentry Logger [log]: Integration installed: Aws
Sentry Logger [log]: Integration installed: AwsLambda
Sentry Logger [log]: Integration installed: Express
Sentry Logger [log]: Running in CommonJS mode. |
You won't need this integration since it gets auto-instrumented out of the box. Does the setup work like this? |
It does not work. Without the
Looking at the code it looks like
|
@relm923 some questions:
|
Transpiring with ESBuild to CJS and explicitly including I'm able to reproduce the same behavior locally without any bundling as well
Everything from RequestData |
Yeah, I guess it is true that we do not set the |
request
not captured in @sentry/aws-serverless
+ express
One question: You wrote this:
Is this some kind of standard, and if so, where is this defined? We get an I will put this in our backlog generally, as we are pretty swamped with stuff right now. PRs are also welcome if you want to take a stab yourself to fix this - you'd have to put code into the |
Generally for AWS Lambda I would expect the raw request/input to the lambda (event & context) and the express request/input (headers, method, etc) both be capture by Sentry. In v7 the express was automatically captured when using the Express integration I would also suggest updating the v8 docs as |
Is this still an issue in v9? We changed some things around the request capturing there! |
@mydea I'm experiencing a problem that resembles this issue: express app deployed via lambda which is missing expected request traces / profiles. For local development my entrypoint is using Here's the entrypoint where Sentry is initialized: // server.ts
// sort-imports-ignore
import * as Sentry from "@sentry/node";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
import { env } from "./env";
Sentry.init({
dsn: env.PILOT_API_SENTRY_DSN,
integrations: [nodeProfilingIntegration()],
environment: env.PILOT_API_SENTRY_ENVIRONMENT,
tracesSampleRate: Number(env.PILOT_API_SENTRY_TRACING_SAMPLE_RATE),
profilesSampleRate: Number(env.PILOT_API_SENTRY_PROFILING_SAMPLE_RATE),
});
import { createApp } from "./app";
import routes from "./routes";
const app = createApp(routes, { enableLogging: true });
const port = env.API_PORT || 4300;
app.listen(port, () => console.log(`Server is listening on port ${port}.`));
export default app; It's giving all the traces / spans I expect! For the deployed lambda I'm using Here's the entrypoint where Sentry is initialized: // lambda.ts
// sort-imports-ignore
import * as Sentry from "@sentry/aws-serverless";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
import { env } from "./src/env";
Sentry.init({
dsn: env.PILOT_API_SENTRY_DSN,
integrations: [
nodeProfilingIntegration(),
// Sentry.expressIntegration(),
// Sentry.redisIntegration(),
// Sentry.postgresIntegration(),
],
environment: env.PILOT_API_SENTRY_ENVIRONMENT,
tracesSampleRate: Number(env.PILOT_API_SENTRY_TRACING_SAMPLE_RATE),
profilesSampleRate: Number(env.PILOT_API_SENTRY_PROFILING_SAMPLE_RATE),
});
import { createApp } from "./src/app";
import serverlessExpress from "@vendia/serverless-express";
import router from "./src/routes";
const app = createApp(router);
export const handler = Sentry.wrapHandler(
serverlessExpress({
app,
logSettings: {
level: "info",
},
}),
);
export default handler; The test error doesn't reveal any useful traces, and bunches everything under In the right sidebar of the traces screen I see: "This transaction does not have any child spans. You can add more child spans via custom instrumentation." If I uncomment those integrations I still get the same result. Lastly, I'm noticing in our Cloudwatch logs that the Lambda is logging warnings:
I believe I've followed the docs. Not sure what I'm missing re: lambda + express configuration. |
The aws integration basically takes over the naming of the spans. I wonder if in your case it wouldn't be better to just disable the aws integration instead 🤔. |
@rowbot-weisguy are you bundling/transpiling your lambda code? If so it will break Sentry OpenTelemetry automatic instrumentation. Need to ensure @andreiborza unfortunately that does appear to be the case. I haven't been able to get Lambda & express spans working together. This did work with Sentry 7 |
@relm923 good point. We use CDK so I've been bundling it using Today, given your advice, I set up a separate layer and marked I'm still noticing the generated issue titles (span names?) are a little unhelpful. In development, using Lovely! The path is so helpful to know immediately. Whereas in deployed lambdas, using So I tried implementing your suggestion @andreiborza: // instrument.lambda.ts
import * as Sentry from "@sentry/aws-serverless";
import { nodeProfilingIntegration } from "@sentry/profiling-node";
import { env } from "./env";
Sentry.init({
dsn: env.PILOT_API_SENTRY_DSN,
defaultIntegrations: false,
integrations: [
...Sentry.getDefaultIntegrations({}).filter(
(integration) => !["Aws", "AwsLambda"].includes(integration.name),
),
nodeProfilingIntegration(),
Sentry.expressIntegration(),
Sentry.redisIntegration(),
Sentry.postgresIntegration(),
],
environment: env.PILOT_API_SENTRY_ENVIRONMENT,
tracesSampleRate: Number(env.PILOT_API_SENTRY_TRACING_SAMPLE_RATE),
profilesSampleRate: Number(env.PILOT_API_SENTRY_PROFILING_SAMPLE_RATE),
});
export const wrapHandler = Sentry.wrapHandler; This change made no visible difference to spans / names, and I'm not sure if there's a different way I should disable the Aws integration. Would love to make sure our Sentry issues are informative at a glance, so please let me know if there's something else I can do here. This is my first time instrumenting Sentry w/ Express & Lambda, so I have no experience with previous versions to share. |
@rowbot-weisguy I created a new issue for the issue title naming as it's not related to the rest of the thread anymore: #15788 |
This issue contains a bunch of semi-related problems by now, some of which have been spinned out into separate issues and some not. It is a bit hard to keep track of what has been changed or not 😅
I will close this issue for now, and would ask you to open new more specific issues if you still encounter such problems on the latest version - as this issue is technically only about capturing the request data on a handler, which should work fine if instrumentation is done according to https://docs.sentry.io/platforms/javascript/guides/aws-lambda/, depending on if your setup uses CJS or ESM. To be clear, there may def. still be something left to do, it is just a bit hard to be sure because the issue became a bit of a catch-all issue for aws related instrumentation issues - please bear with us and open a new issue with as much details as possible if problems persist, thank you! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
8.37.1
Framework Version
AWS Lambda + Express 4.21.1
Link to Sentry event
https://patina-health.sentry.io/issues/5996169896?project=6044571
Reproduction Example/SDK Setup
Steps to Reproduce
Run the above code ideally deployed to AWS. Invoke with payload similar to:
Error is reported to Sentry but the
request
information is not includedExpected Result
Sentry event should include the
request
information.This worked correctly with the same setup on Sentry 7
Actual Result
Sentry event does include
aws.cloudwatch.logs
andaws.lambda
but no request informationThe text was updated successfully, but these errors were encountered: