GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(aws-serverless): Extract sentry trace data from handler `context` over `event` by andreiborza · Pull Request #13266 · getsentry/sentry-javascript Conversation
|
size-limit report 📦
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| hasBundles: true, | ||
| packageSpecificConfig: { | ||
| // Used for our custom eventContextExtractor | ||
| external: ['@opentelemetry/api'], |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
just out of curiosity, why is this needed?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Package build structure isn't right without this. It pulls this in under its own node_modules folder.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * Sentry's context. This should usually be `true` when | ||
| * using Sentry to instrument Lambdas. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| * Sentry's context. This should usually be `true` when | |
| * using Sentry to instrument Lambdas. | |
| * Sentry's context. Defaults to `true`, in order for Sentry trace propagation to take precedence, | |
| * but can be disabled if you want to AWS propagation to take precedence. |
or something like this?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| import { awsIntegration } from './integration/aws'; | ||
| import { awsLambdaIntegration } from './integration/awslambda'; | ||
| import { markEventUnhandled } from './utils'; | ||
| import { getTraceData, markEventUnhandled } from './utils'; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
m: Can we change the name here, as it conflicts with getTraceData we have in core, making this possibly a bit confusing 😅 E.g. getAwsTraceData or something like this?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yep, good point.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const customContext: Record<string, unknown> = context.clientContext.Custom; | ||
| const sentryTrace = isString(customContext['sentry-trace']) ? customContext['sentry-trace'] : undefined; | ||
|
|
||
| if (sentryTrace) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
m: It will probably not matter in 99% of cases, but let's just split this into two if-blocks. So basically:
const sentryTrace = ...; const baggage = ...; if(sentryTrace) { traceData['sentry-trace'] = sentryTrace; } if(baggage) { traceData.baggage = baggage; }
I think this is slightly more robust :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of that, but wouldn't we potentially end up with a mix of wrong pairs, e.g. both event and context have baggage but only event has sentry-trace. So we end up with sentry-trace from event and baggage from context.
I don't know if that's a realistic usecase tho. In core, we also throw away baggage if sentryTrace is not valid.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
right, then let's keep it this way, all good! 👍
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| /** | ||
| * Extracts sentry trace data from the handler `context` if available and falls | ||
| * back to the `event`. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can also add a short note here when this would be on context and when on event?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I added an explanation, but tbh this is pretty wide open. I think different AWS services make use of different event/context usage. Hope this adds a bit more info?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
left some notes, more about details - overall great work! Big improvement :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Spans in continueTrace callback are not being recorded
There was an error while loading. Please reload this page.