Skip to content

Issue titles from errors captured with @sentry/aws-serverless differ from @sentry/node #15788

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

Closed
s1gr1d opened this issue Mar 24, 2025 · 4 comments

Comments

@s1gr1d
Copy link
Member

s1gr1d commented Mar 24, 2025

Description

Originally posted in this comment by @rowbot-weisguy

@relm923 good point. We use CDK so I've been bundling it using esbuild via aws-cdk-lib/aws-lambda-nodejs.

Today, given your advice, I set up a separate layer and marked express as an external module. It works! Warning is gone and I managed to get traces that I wanted to see from the lambda as long as I explicitly include the integrations I care about (e.g. expressIntegration, redisIntegration, and postgresIntegration).

I'm still noticing the generated issue titles (span names?) are a little unhelpful.

In development, using @sentry/node I see:

Image

Lovely! The path is so helpful to know immediately. Whereas in deployed lambdas, using @sentry/aws-serverless I see:

Image

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.

Image

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.

@s1gr1d
Copy link
Member Author

s1gr1d commented Mar 24, 2025

@rowbot-weisguy The @sentry/aws-serverless SDK sets the transaction name based on the function name we get from the AWS Lambda context (see code here).

That's the reason why the naming is different to the @sentry/node SDK which you are using in development mode. Does the naming resemble the AWS Lambda function name or is this not correct either?

@rowbot-weisguy
Copy link

@s1gr1d thanks for creating a new issue for me. That's correct, the transaction names are using our lambda's name.

Is it possible to have it use the request path instead?

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Mar 24, 2025
@s1gr1d
Copy link
Member Author

s1gr1d commented Mar 25, 2025

You can change the transaction name based on what is documented here: https://docs.sentry.io/platforms/javascript/guides/aws-lambda/enriching-events/transaction-name/

Does that work for your case?

@getsantry
Copy link

getsantry bot commented May 14, 2025

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label May 14, 2025
@getsantry getsantry bot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
Archived in project
Development

No branches or pull requests

5 participants