Skip to content

feat(elysia): Elysia SDK - #19509

Merged
logaretm merged 22 commits into
developfrom
awad/js-1542-add-elysia-integration
Mar 24, 2026
Merged

feat(elysia): Elysia SDK#19509
logaretm merged 22 commits into
developfrom
awad/js-1542-add-elysia-integration

Conversation

@logaretm

@logaretmlogaretm commented Feb 24, 2026

Copy link
Copy Markdown
Member

Key Decisions:

  • Built on @sentry/bun since Elysia is Bun-first.
  • We uses Elysia's first-party OTel plugin for lifecycle instrumentation instead of rolling our own.
  • We had to filter out bunServerIntegration to avoid competing root spans, as Elysia creates its own.
  • Error handling: Captures 5xx and <= 299, skips 3xx/4xx. Aligned with Fastify. Overridable via shouldHandleError.
  • Client hooks registered once via module-level guard, safe to call withElysia() multiple times.
  • Elysia produces empty child spans for arrow function handlers. We collect their IDs in spanEnd (still empty at that point) and strip them in beforeSendEvent. Unless the user provides a named function, we will strip them, check the trace below as an example of a named function logRequest vs the stripped event handlers in other life cycle hooks.
CleanShot 2026-03-05 at 15 19 34@2xCleanShot 2026-03-05 at 15 02 12@2x

TODOs:

  • Plugin API to address registration order.
  • Figure out a way to drop the root span or parameterize it.
  • Transform into an SDK

Closes#18956

@linear

linearBot commented Feb 24, 2026

Copy link
Copy Markdown

JS-1542 Add Elysia

@github-actions

github-actionsBot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

PathSize% ChangeChange
@sentry/browser25.69 kB+0.2%+49 B 🔺
@sentry/browser - with treeshaking flags24.17 kB+0.14%+33 B 🔺
@sentry/browser (incl. Tracing)42.67 kB+0.13%+54 B 🔺
@sentry/browser (incl. Tracing, Profiling)47.33 kB+0.12%+55 B 🔺
@sentry/browser (incl. Tracing, Replay)81.48 kB+0.08%+57 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags71.06 kB+0.1%+69 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)86.17 kB+0.06%+50 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)98.41 kB+0.04%+36 B 🔺
@sentry/browser (incl. Feedback)42.48 kB+0.08%+30 B 🔺
@sentry/browser (incl. sendFeedback)30.35 kB+0.15%+43 B 🔺
@sentry/browser (incl. FeedbackAsync)35.4 kB+0.12%+39 B 🔺
@sentry/browser (incl. Metrics)26.96 kB+0.15%+38 B 🔺
@sentry/browser (incl. Logs)27.1 kB+0.12%+32 B 🔺
@sentry/browser (incl. Metrics & Logs)27.78 kB+0.15%+39 B 🔺
@sentry/react27.45 kB+0.22%+58 B 🔺
@sentry/react (incl. Tracing)45.01 kB+0.14%+60 B 🔺
@sentry/vue30.13 kB+0.16%+46 B 🔺
@sentry/vue (incl. Tracing)44.52 kB+0.09%+39 B 🔺
@sentry/svelte25.7 kB+0.16%+40 B 🔺
CDN Bundle28.35 kB+0.27%+75 B 🔺
CDN Bundle (incl. Tracing)43.57 kB+0.15%+62 B 🔺
CDN Bundle (incl. Logs, Metrics)29.22 kB+0.27%+77 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics)44.43 kB+0.17%+75 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics)68.29 kB+0.13%+85 B 🔺
CDN Bundle (incl. Tracing, Replay)80.41 kB+0.1%+73 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)81.31 kB+0.1%+76 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)85.97 kB+0.12%+103 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)86.86 kB+0.1%+86 B 🔺
CDN Bundle - uncompressed82.7 kB+0.1%+77 B 🔺
CDN Bundle (incl. Tracing) - uncompressed128.62 kB+0.05%+64 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed85.57 kB+0.1%+77 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed131.49 kB+0.05%+64 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed209.22 kB+0.05%+102 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed245.5 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed248.35 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed258.41 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed261.26 kB+0.04%+89 B 🔺
@sentry/nextjs (client)47.4 kB+0.08%+37 B 🔺
@sentry/sveltekit (client)43.12 kB+0.12%+51 B 🔺
@sentry/node-core56.42 kB+0.13%+72 B 🔺
@sentry/node170.71 kB-1.42%-2.44 kB 🔽
@sentry/node - without tracing96.45 kB+0.11%+105 B 🔺
@sentry/aws-serverless113.54 kB+0.18%+202 B 🔺

View base workflow run

@github-actions

github-actionsBot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

ScenarioRequests/s% of BaselinePrev. Requests/sChange %
GET Baseline9,587-8,837+8%
GET With Sentry1,68218%1,581+6%
GET With Sentry (error only)6,04663%5,836+4%
POST Baseline1,181-1,170+1%
POST With Sentry58550%561+4%
POST With Sentry (error only)1,04088%1,019+2%
MYSQL Baseline3,249-3,195+2%
MYSQL With Sentry49015%406+21%
MYSQL With Sentry (error only)2,63481%2,586+2%

View base workflow run

@logaretmlogaretm changed the title feat(node-core/bun): Add Elysia Integrationfeat(elysia): Elysia SDKMar 5, 2026
@logaretm
logaretmforce-pushed the awad/js-1542-add-elysia-integration branch 10 times, most recently from 7d220e3 to 672ad18CompareMarch 11, 2026 20:32
@logaretm
logaretm marked this pull request as ready for review March 12, 2026 03:42
CopilotAI review requested due to automatic review settings March 12, 2026 03:42
Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment threadpackages/elysia/src/withElysia.ts
Comment thread.size-limit.js

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new @sentry/elysia package to the monorepo to provide first-party Sentry support for the Elysia framework (Bun-first), including SDK initialization, Elysia app wiring, and E2E coverage.

Changes:

  • Introduces the new @sentry/elysia package (build config, exports, types, README/license, unit tests).
  • Implements init() (built on @sentry/bun) and withElysia() (OTel plugin + request/error hooks + span cleanup/enrichment).
  • Adds a Bun + Elysia Playwright E2E test application and wires it into CI/publishing metadata.

Reviewed changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
yarn.lockAdds Elysia + OTel plugin dependency graph and related transitive updates.
packages/elysia/tsconfig.types.jsonType build config for generating .d.ts output.
packages/elysia/tsconfig.test.jsonTest TS config (Bun types) for the new package.
packages/elysia/tsconfig.jsonPackage TS config (Bun types) for source compilation.
packages/elysia/test/withElysia.test.tsUnit tests for withElysia() hook registration, header propagation, and error capturing behavior.
packages/elysia/test/sdk.test.tsUnit tests for init() and getDefaultIntegrations() behavior.
packages/elysia/src/withElysia.tsCore Elysia wiring: OTel plugin registration, request metadata, response header propagation, error capture, span filtering/enrichment.
packages/elysia/src/types.tsDefines ElysiaOptions as BunOptions.
packages/elysia/src/sdk.tsImplements init() and Bun default integration filtering.
packages/elysia/src/index.tsPublic API surface: re-exports from @sentry/bun plus Elysia-specific exports.
packages/elysia/rollup.npm.config.mjsRollup config for publishing build artifacts.
packages/elysia/package.jsonNew package manifest (deps/peers/scripts/exports).
packages/elysia/README.mdUsage documentation and links for the new SDK.
packages/elysia/LICENSEPackage license file.
packages/elysia/.eslintrc.jsPackage-local ESLint configuration.
package.jsonAdds packages/elysia workspace + new resolutions for OTel packages.
dev-packages/e2e-tests/verdaccio-config/config.yamlAllows publishing @sentry/elysia to local registry for E2E tests.
dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.tsUpdates export consistency checks (ignore list additions).
dev-packages/e2e-tests/test-applications/bun-elysia/tsconfig.jsonTS config for the new Bun+Elysia E2E app.
dev-packages/e2e-tests/test-applications/bun-elysia/tests/transactions.test.tsE2E validation for transactions, route parameterization, lifecycle spans, and manual spans.
dev-packages/e2e-tests/test-applications/bun-elysia/tests/propagation.test.tsE2E validation for inbound propagation headers + documented fixmes for outbound propagation gaps.
dev-packages/e2e-tests/test-applications/bun-elysia/tests/isolation.test.tsDocumented fixme for per-request isolation behavior.
dev-packages/e2e-tests/test-applications/bun-elysia/tests/errors.test.tsE2E validation for error capture rules and request metadata inclusion.
dev-packages/e2e-tests/test-applications/bun-elysia/start-event-proxy.mjsStarts local event proxy for E2E capture.
dev-packages/e2e-tests/test-applications/bun-elysia/src/app.tsE2E fixture Elysia app exercising routes, errors, propagation, and concurrency.
dev-packages/e2e-tests/test-applications/bun-elysia/playwright.config.mjsPlaywright runner config for the new E2E app.
dev-packages/e2e-tests/test-applications/bun-elysia/package.jsonE2E app manifest (depends on @sentry/elysia).
dev-packages/e2e-tests/test-applications/bun-elysia/.npmrcPoints test app to local Verdaccio.
dev-packages/e2e-tests/test-applications/bun-elysia/.gitignoreIgnores build output for the E2E app.
README.mdAdds @sentry/elysia to the list of SDKs.
.size-limit.jsAdjusts bundle size limits (likely due to dependency graph changes).
.github/workflows/build.ymlEnsures Bun is set up for the new bun-elysia E2E matrix entry.
.github/ISSUE_TEMPLATE/bug.ymlAdds @sentry/elysia to bug report SDK dropdown.
.craft.ymlAdds publishing target configuration for @sentry/elysia.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment threadpackages/elysia/src/withElysia.ts
Comment threadpackages/elysia/src/withElysia.ts
Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment on lines +22 to +59
function getRuntime(): { name: string; version: string } {
if (typeof Bun !== 'undefined') {
return { name: 'bun', version: Bun.version };
}

return { name: 'node', version: process.version };
}

/**
* Initializes the Sentry Elysia SDK.
*
* @example
* ```javascript
* import * as Sentry from '@sentry/elysia';
*
* Sentry.init({
* dsn: '__DSN__',
* tracesSampleRate: 1.0,
* });
* ```
*/
export function init(userOptions: ElysiaOptions = {}): NodeClient | undefined {
applySdkMetadata(userOptions, 'elysia');

const options = {
...userOptions,
platform: 'javascript',
runtime: getRuntime(),
serverName: userOptions.serverName || global.process.env.SENTRY_NAME || os.hostname(),
};

options.transport = options.transport || makeFetchTransport;

if (options.defaultIntegrations === undefined) {
options.defaultIntegrations = getDefaultIntegrations(options);
}

return initNode(options);

CopilotAIMar 12, 2026

Copy link

Choose a reason for hiding this comment

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

getRuntime() falls back to { name: 'node', version: process.version } when Bun is undefined, but init() still calls init from @sentry/bun. The Bun SDK’s init references Bun.version internally, so calling @sentry/elysia.init() in a non-Bun runtime will still throw at runtime. Either explicitly enforce Bun-only usage (and throw a clear error when Bun is undefined) or conditionally use a Node-compatible init implementation when running on Node.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be relevant no? Not sure how it behaves actually if Elysia is called in a Node environment.

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.

Good catch, I haven't tried it out, I think I will fix it in the bun SDK and maybe add a node variant test for elysia just in case.

Comment threadpackages/elysia/src/withElysia.ts
Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment threadpackages/elysia/src/withElysia.ts Outdated
Comment threadpackages/elysia/src/sdk.ts
@logaretm
logaretmforce-pushed the awad/js-1542-add-elysia-integration branch from 19113b3 to 68051afCompareMarch 12, 2026 04:59
Comment threadpackages/elysia/src/clientHooks.ts Outdated
Comment threadpackage.json
@logaretm
logaretmforce-pushed the awad/js-1542-add-elysia-integration branch from 68051af to 88952b2CompareMarch 16, 2026 14:25
logaretmand others added 17 commits March 23, 2026 14:18
On Node.js, the root HTTP span is created by Node's HTTP instrumentation
with only the raw URL. The Elysia OTel plugin creates a child span with
route info but doesn't propagate it up. This updates the root span and
isolation scope with the parameterized route name in onAfterHandle (for
successful requests on Node.js) and onError (for all runtimes).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node 20 does not support running .ts files directly. Node 24 has
TypeScript stripping enabled by default.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@logaretm
logaretmforce-pushed the awad/js-1542-add-elysia-integration branch from e35f523 to 1d4ea2aCompareMarch 23, 2026 18:18
logaretm added a commit to getsentry/platformicons that referenced this pull request Mar 24, 2026
Add SVG icons for the Elysia web framework in both standard (20x20)
and large (80x80) sizes, sourced from the official Elysia logo.
Ref: getsentry/sentry-javascript#19509
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
logaretm added a commit to getsentry/sentry-docs that referenced this pull request Mar 24, 2026
Add getting started guide for the new @sentry/elysia package covering
Bun and Node.js runtimes, error capturing, automatic tracing, and
distributed trace propagation. Wire up the Elysia platform icon.
Refs getsentry/sentry-javascript#19509
Co-Authored-By: Claude <noreply@anthropic.com>
@logaretm
logaretm merged commit 18a624e into developMar 24, 2026
238 of 239 checks passed
@logaretm
logaretm deleted the awad/js-1542-add-elysia-integration branch March 24, 2026 19:28
@github-actionsgithub-actionsBot mentioned this pull request Mar 25, 2026
logaretm added a commit to getsentry/sentry-docs that referenced this pull request Mar 27, 2026
Add getting started guide for the new @sentry/elysia package covering
Bun and Node.js runtimes, error capturing, automatic tracing, and
distributed trace propagation. Wire up the Elysia platform icon.
Refs getsentry/sentry-javascript#19509
Co-Authored-By: Claude <noreply@anthropic.com>
logaretm added a commit to getsentry/sentry-docs that referenced this pull request Apr 1, 2026
Add getting started guide for the new @sentry/elysia package covering
Bun and Node.js runtimes, error capturing, automatic tracing, and
distributed trace propagation. Wire up the Elysia platform icon.
Refs getsentry/sentry-javascript#19509
Co-Authored-By: Claude <noreply@anthropic.com>
logaretm added a commit to getsentry/sentry-docs that referenced this pull request Apr 2, 2026
## DESCRIBE YOUR PR
Add getting started documentation for the new `@sentry/elysia` package,
a Sentry SDK for the [Elysia](https://elysiajs.com/) web framework.
- New guide at `docs/platforms/javascript/guides/elysia/` covering Bun
and Node.js runtimes
- Error capturing, automatic lifecycle tracing, distributed tracing, and
manual spans
- Platform icon wiring in `platformIcon.tsx`
### Blocked on
- [x] **SDK implementation**:
getsentry/sentry-javascript#19509
- [x] **Platform icon**:
getsentry/platformicons#234 (then bump
`platformicons` version here)
## IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.):
- [ ] Other deadline:
- [x] None: Not urgent, can wait up to 1 week+
## SLA
- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!
## PRE-MERGE CHECKLIST
*Make sure you've checked the following before merging your changes:*
- [x] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Co-authored-by: Sarah Mischinger <sarah@codingwriter.com>
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.

Add Elysia

5 participants

@logaretm@JPeer264@chargome@s1gr1d