Skip to content

ref(aws-serverless): Streamline AwsLambda instrumentation - #21758

Merged
nicohrubec merged 9 commits into
developfrom
nh/streamline-aws-lambda
Jun 25, 2026
Merged

ref(aws-serverless): Streamline AwsLambda instrumentation#21758
nicohrubec merged 9 commits into
developfrom
nh/streamline-aws-lambda

Conversation

@nicohrubec

@nicohrubecnicohrubec commented Jun 24, 2026

Copy link
Copy Markdown
Member

Streamlines the AWS Lambda instrumentation:

  • Folds the requestHook (origin/op) and responseHook (error capture) into the instrumentation, removing the hook config.
  • Uses startInactiveSpan/withActiveSpan from @sentry/core instead of the OTel tracer (span kind preserved via the kind option).
  • Uses continueTrace from @sentry/core for incoming trace propagation instead of the OTel propagation primitives (propagation.extract/context.with).
  • Removes unused code: the internal eventContextExtractor config and default extractor, internal-types.ts (inlines LambdaModule), and the dead disableAwsContextPropagation default (option deprecated for v11 removal).
  • Moves OTel diag logging to Sentry's debug.
  • Adds callback-style and trace-propagation integration tests.

Closes#21746

nicohrubecand others added 2 commits June 24, 2026 15:48
… e2e coverage
Adds e2e cases for callback-style handlers (success + error) and trace
continuation from incoming headers, covering paths the existing async-only
suite missed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Create the Lambda span via the `@sentry/core` `startInactiveSpan` API (within the
extracted parent context) instead of the OTel tracer, and fold the integration's
`requestHook` (origin/op) and `responseHook` (captureException) directly into the
instrumentation. `otel.kind: SERVER` is preserved via the `kind` option.
Ref JS-2849
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

Copy link
Copy Markdown

JS-2849

@github-actions

github-actionsBot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.47 kB--
@sentry/browser - with treeshaking flags25.91 kB--
@sentry/browser (incl. Tracing)45.97 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.72 kB--
@sentry/browser (incl. Tracing, Profiling)50.76 kB--
@sentry/browser (incl. Tracing, Replay)85.22 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.81 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.91 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.57 kB--
@sentry/browser (incl. Feedback)44.66 kB--
@sentry/browser (incl. sendFeedback)32.26 kB--
@sentry/browser (incl. FeedbackAsync)37.4 kB--
@sentry/browser (incl. Metrics)28.54 kB--
@sentry/browser (incl. Logs)28.78 kB--
@sentry/browser (incl. Metrics & Logs)29.47 kB--
@sentry/react29.27 kB--
@sentry/react (incl. Tracing)48.28 kB--
@sentry/vue32.63 kB--
@sentry/vue (incl. Tracing)47.84 kB--
@sentry/svelte27.5 kB--
CDN Bundle29.89 kB--
CDN Bundle (incl. Tracing)47.89 kB--
CDN Bundle (incl. Logs, Metrics)31.44 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.24 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.78 kB--
CDN Bundle (incl. Tracing, Replay)85.4 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.68 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.19 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.45 kB--
CDN Bundle - uncompressed88.94 kB--
CDN Bundle (incl. Tracing) - uncompressed145.03 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed93.65 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed149 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.62 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed264.05 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed268 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed277.75 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed281.69 kB--
@sentry/nextjs (client)50.67 kB--
@sentry/sveltekit (client)46.37 kB--
@sentry/core/server77.28 kB--
@sentry/core/browser63.63 kB--
@sentry/node-core61.51 kB+0.01%+1 B 🔺
@sentry/node122.65 kB--
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.4 kB--
@sentry/node - without tracing73.55 kB+0.01%+1 B 🔺
@sentry/aws-serverless84.33 kB-0.48%-401 B 🔽
@sentry/cloudflare (withSentry) - minified180.31 kB--
@sentry/cloudflare (withSentry)446.24 kB--

View base workflow run

@nicohrubec
nicohrubec changed the base branch from nh/aws-lambda-tests to developJune 24, 2026 14:16
nicohrubecand others added 4 commits June 24, 2026 16:26
…gging
Remove the vendored internal-types.ts (inline the one-line LambdaModule type)
and replace OTel `diag` logging with Sentry's `debug` (gated on DEBUG_BUILD),
dropping the `diag` import.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cate disableAwsContextPropagation
The eventContextExtractor option was hardcoded and never user-overridable, so
inline Sentry's extractor directly and remove the unreachable default extractor
(and the now-unused headerGetter/propagation plumbing). Deprecate the
disableAwsContextPropagation option, which has been a no-op, and drop its dead
default in the instrument factory.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… v11 removal
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ation
Replace the OTel propagation plumbing (propagation.extract + otelContext.with +
trace.getSpan/ROOT_CONTEXT and the internal eventContextExtractor) with
@sentry/core `continueTrace`, fed by `getAwsTraceData`. The Lambda span is now
created inside `continueTrace`, continuing the incoming trace natively, and
`_determineParent` is removed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Sentry trace propagation to take precedence, but can
* be disabled if you want AWS propagation to take take
* precedence.
* @deprecated This option no longer does anything and will be removed in a future major version.

@nicohrubecnicohrubecJun 25, 2026

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not missing anything this option was already dead?

@nicohrubec
nicohrubec marked this pull request as ready for review June 25, 2026 08:07
@nicohrubec
nicohrubec requested a review from a team as a code ownerJune 25, 2026 08:07
@nicohrubec
nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a teamJune 25, 2026 08:07
nicohrubecand others added 2 commits June 25, 2026 10:30
Replace the magic kind number with the `SPAN_KIND` const from `@sentry/core`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…instrumentation
Sentry does not use OTel metrics and the meter-provider force-flush was never
documented, so remove the setMeterProvider override, _metricForceFlush, and the
metrics flush in _endSpan. Trace force-flush is kept.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec
nicohrubec merged commit cb014b9 into developJun 25, 2026
53 checks passed
@nicohrubec
nicohrubec deleted the nh/streamline-aws-lambda branch June 25, 2026 11:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamline AwsLambdaInstrumentation

2 participants

@nicohrubec@andreiborza