-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
graphqlIntegration does not rename the root span with the operation name in AWS Lambda #15699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @nickygb, thanks for filing this. I'll look into this, but it might take some time to get to it. |
Following up on this, I am not sure if this is working at all 🤔 the So your problem has nothing to do with the Could you enable |
|
Can you also share the logs for startup, including the |
And is whatever is interacting with graphql bundled into your lambda function? We can't instrument bundled in dependencies. |
I use grapqhl 15.10.1 Here are the logs:
This is an example of what i I see in tracing view in Sentry: there is a trace graphql.parse created but not linked to anything. I start the transaction from my react app. And pass the baggage and sentry-trace headers |
Hey, Im passing the headers like this. export const handleHttp = Sentry.wrapHandler(
async (event: APIGatewayEvent, context: Context) => {
try {
const aggregatedOperationNames = extractGraphqlOperationNames(event);
const sentryTraceHeader = event.headers?.['sentry-trace'];
const baggageHeader = event.headers?.['baggage'];
const apolloServerHandler = (await getServer()).createHttpHandler({
cors: {
origin: '*',
allowedHeaders: ['sentry-trace', 'baggage'],
credentials: true,
},
});
return sentryTraceHeader && baggageHeader
? Sentry.continueTrace(
{ sentryTrace: sentryTraceHeader, baggage: baggageHeader },
() =>
Sentry.startSpan(
{
op: 'http.server',
name: `POST /graphql (query ${aggregatedOperationNames})`,
},
() => {
return apolloServerHandler(event, context);
}
)
)
: Sentry.startSpan(
{
op: 'http.server',
name: `POST /graphql (query ${aggregatedOperationNames})`,
},
() => {
return apolloServerHandler(event, context);
}
);
} catch (err) {
logger.error(`[ERROR] Exception during handler execution: ${err}`);
throw err;
} finally {
cleanupResources();
}
},
{ startTrace: false }
); I have tried also with startTrace: true and assuming that the headers are passed automatically on the sentry wrapper, but still not works. |
If I remember correctly, by default, the headers are extracted from the context. Can you try logging both event and context to see if you even get a sentry-trace and baggage? |
I got this in the event:
This is the context:
|
Hy, I created a PR that will update the root span name directly in the GraphQL integration: #16010 This will hopefully fix your issue once it is merged. |
A PR closing this issue has just been released 🚀This issue was referenced by PR #16010, which was included in the 9.13.0 release. |
I'm still experiencing issues with the GraphQL integration not renaming the root span in AWS Lambda, even after upgrading to version 9.13.0 where this fix was supposedly included. Current behavior:
Lambda handler configuration: export const handleHttp = Sentry.wrapHandler(
async (event: APIGatewayEvent, context: Context) => {
const server = await getServer();
try {
// Extract operation names if possible
const sentryTraceHeader = event.headers?.['sentry-trace'];
const baggageHeader = event.headers?.['baggage'];
// If headers exist, continue the trace
if (sentryTraceHeader && baggageHeader) {
return Sentry.continueTrace(
{ sentryTrace: sentryTraceHeader, baggage: baggageHeader },
() =>
Sentry.startSpan({ op: 'http.server', name: 'POST /graphql' }, () =>
server.createHttpHandler({
cors: {
origin: '*',
allowedHeaders: ['sentry-trace', 'baggage'],
credentials: true,
},
})(event, context)
)
);
}
// Otherwise proceed normally
return await server.createHttpHandler({
cors: {
origin: '*',
allowedHeaders: ['sentry-trace', 'baggage'],
credentials: true,
},
})(event, context);
} catch (err) {
logger.error(`[ERROR] Exception during handler execution: ${err}`);
throw err;
} finally {
cleanupResources();
}
},
{ startTrace: false }
); I've also tried a simpler approach without manually setting the span with op 'http.server' and with Environment:
I've verified that PR #16010 was supposed to fix this issue, but it doesn't seem to be working in my environment. Is there something specific about AWS Lambda that might be preventing the fix from working correctly? Or are there additional configuration steps needed to make this work? Any additional guidance would be greatly appreciated, as having meaningful transaction names is critical for our monitoring. |
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×tamp=1742149537.396
Reproduction Example/SDK Setup
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.Lambda handler:
The issue is that in AWS Lambda, the root span is not
http.server
butfunction.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.
The text was updated successfully, but these errors were encountered: