Skip to content

graphqlIntegration does not rename the root span with the operation name in AWS Lambda #15699

Closed
@nickygb

Description

@nickygb

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

9.5.0

Framework Version

No response

Link to Sentry event

https://bilderit.sentry.io/traces/trace/dc6845bb99a44bb69609a74dc394258f/?environment=pr1687&node=span-91982ffd2de5504c&node=txn-304389edaa5e4227be7f3f1424d1ac0d&pageEnd&pageStart&project=5263245&source=traces&statsPeriod=1h&table=trace&timestamp=1742149537.396

Reproduction Example/SDK Setup

Sentry.init({
  dsn: 'YOUR_SENTRY_DSN',
  release: 'YOUR_SENTRY_RELEASE',
  environment: 'YOUR_SENTRY_ENVIRONMENT',
  tracesSampleRate: 0.1,
  profilesSampleRate: 0.1,
  maxValueLength: 2000,
  integrations: [
    Sentry.rewriteFramesIntegration({ root: process.cwd() }),
    Sentry.graphqlIntegration({
      ignoreResolveSpans: false,
      useOperationNameForRootSpan: true,
    }),
    Sentry.knexIntegration(),
    Sentry.postgresIntegration(),
    nodeProfilingIntegration(),
  ],
  _experiments: {
    maxSpans: 'YOUR_SENTRY_RELEASE' !== 'prod' ? 10000 : 1000,
  },
});

Steps to Reproduce

I'm using Sentry.graphqlIntegration({ useOperationNameForRootSpan: true }) in an AWS Lambda with Apollo Server. According to the documentation, this should rename the root http.server span with the GraphQL operation name.

// instrumentation.ts

Sentry.init({
  dsn: 'YOUR_SENTRY_DSN',
  release: 'YOUR_SENTRY_RELEASE',
  environment: 'YOUR_SENTRY_ENVIRONMENT',
  tracesSampleRate: 0.1,
  profilesSampleRate: 0.1,
  maxValueLength: 2000,
  integrations: [
    Sentry.rewriteFramesIntegration({ root: process.cwd() }),
    Sentry.graphqlIntegration({
      ignoreResolveSpans: false,
      useOperationNameForRootSpan: true,
    }),
    Sentry.knexIntegration(),
    Sentry.postgresIntegration(),
    nodeProfilingIntegration(),
  ],
  _experiments: {
    maxSpans: 'YOUR_SENTRY_RELEASE' !== 'prod' ? 10000 : 1000,
  },
});

Lambda handler:

import './instrumentation';

export const handleHttp = Sentry.wrapHandler(
  async (event: APIGatewayEvent, context: Context) => {
    const server = await getServer();
    return await server.createHttpHandler({
      cors: {
        origin: '*',
        allowedHeaders: ['sentry-trace', 'baggage'],
        credentials: true,
      },
    })(event, context);
  }
);

The issue is that in AWS Lambda, the root span is not http.server but function.aws.lambda, so graphqlIntegration never renames it.

Expected Result

  • The root span should be http.server and renamed to include the GraphQL operation name (e.g., POST /graphql (query operationName)).

  • The trace should correctly reflect the operation name in the root span, instead of the default lambda function name.

Actual Result

  • There is no op: http.server span, only function.aws.lambda.

  • graphqlIntegration does not rename the root span name with the graphql operation name. The name of the root operation is the name of the Lambda Function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: aws-serverlessIssues related to the Sentry AWS Serverless SDK

    Type

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions