-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(elysia): Elysia SDK #19509
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
Open
logaretm
wants to merge
21
commits into
develop
Choose a base branch
from
awad/js-1542-add-elysia-integration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,637
−68
Open
feat(elysia): Elysia SDK #19509
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ca6954e
feat(elysia): Add Elysia SDK
logaretm da9558e
fix: add all required entries to craft
logaretm cc505c2
fix: apply the sdk stack metadata
logaretm 8b5bffe
fix: error handling mechanism name
logaretm 8cd0605
fix: update versions
logaretm 102e7e9
chore: license date
logaretm f93f9a2
chore: use oxlint for elysia
logaretm 2471c27
refactor: one less ternary
logaretm b4923c1
refactor: use optional prop type over partial for now
logaretm 8bb47f9
chore: cleanup left over consistent export assertion
logaretm 742bfa7
ref: use one loop to filter out spans
logaretm 7d9f06d
chore: bump again
logaretm 2bae677
chore: regen lock
logaretm 3e658e3
chore: update tests and added node variant
logaretm 8adbe73
fix: avoid touching bun namespace for downstream packages
logaretm e9f9657
test: added an eslysia node app
logaretm fa54c95
test: use the node adapter
logaretm 116043a
test: fix test assertion
logaretm ac1c608
fix: update root span with parameterized route name on Node.js
logaretm 38ac16b
chore: bump test node version
logaretm e35f523
chore: bump elysia-node test app to Node 24 for native TS support
logaretm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @sentry:registry=http://127.0.0.1:4873 | ||
| @sentry-internal:registry=http://127.0.0.1:4873 |
26 changes: 26 additions & 0 deletions
26
dev-packages/e2e-tests/test-applications/elysia-bun/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "name": "elysia-bun-app", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "start": "bun src/app.ts", | ||
| "test": "playwright test", | ||
| "clean": "npx rimraf node_modules pnpm-lock.yaml", | ||
| "test:build": "pnpm install", | ||
| "test:assert": "pnpm test" | ||
| }, | ||
| "dependencies": { | ||
| "@elysiajs/opentelemetry": "^1.4.0", | ||
| "@sentry/elysia": "latest || *", | ||
| "elysia": "^1.4.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "~1.56.0", | ||
| "@sentry-internal/test-utils": "link:../../../test-utils", | ||
| "bun-types": "^1.2.9" | ||
| }, | ||
| "volta": { | ||
| "extends": "../../package.json" | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
dev-packages/e2e-tests/test-applications/elysia-bun/playwright.config.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { getPlaywrightConfig } from '@sentry-internal/test-utils'; | ||
|
|
||
| const config = getPlaywrightConfig({ | ||
| startCommand: 'bun src/app.ts', | ||
| }); | ||
|
|
||
| export default config; |
142 changes: 142 additions & 0 deletions
142
dev-packages/e2e-tests/test-applications/elysia-bun/src/app.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| import * as Sentry from '@sentry/elysia'; | ||
| import { Elysia } from 'elysia'; | ||
|
|
||
| Sentry.init({ | ||
| environment: 'qa', // dynamic sampling bias to keep transactions | ||
| dsn: process.env.E2E_TEST_DSN, | ||
| tunnel: `http://localhost:3031/`, // proxy server | ||
| tracesSampleRate: 1, | ||
| tracePropagationTargets: ['http://localhost:3030', '/external-allowed'], | ||
| }); | ||
|
|
||
| const app = Sentry.withElysia(new Elysia()); | ||
|
|
||
| // Simple success route | ||
| app.get('/test-success', () => ({ version: 'v1' })); | ||
|
|
||
| // Parameterized route | ||
| app.get('/test-param/:param', ({ params }) => ({ paramWas: params.param })); | ||
|
|
||
| // Multiple params | ||
| app.get('/test-multi-param/:param1/:param2', ({ params }) => ({ | ||
| param1: params.param1, | ||
| param2: params.param2, | ||
| })); | ||
|
|
||
| // Route that throws an error (will be caught by onError) | ||
| app.get('/test-exception/:id', ({ params }) => { | ||
| throw new Error(`This is an exception with id ${params.id}`); | ||
| }); | ||
|
|
||
| // Route with a custom span | ||
| app.get('/test-transaction', () => { | ||
| Sentry.startSpan({ name: 'test-span' }, () => { | ||
| Sentry.startSpan({ name: 'child-span' }, () => {}); | ||
| }); | ||
| return { status: 'ok' }; | ||
| }); | ||
|
|
||
| // Route with specific middleware via .guard or .use | ||
| app.group('/with-middleware', app => | ||
| app | ||
| .onBeforeHandle(() => { | ||
| // This is a route-specific middleware | ||
| }) | ||
| .get('/test', () => ({ middleware: true })), | ||
| ); | ||
|
|
||
| // Error with specific status code | ||
| app.post('/test-post-error', () => { | ||
| throw new Error('Post error'); | ||
| }); | ||
|
|
||
| // Route that returns a non-500 error | ||
| app.get('/test-4xx', ({ set }) => { | ||
| set.status = 400; | ||
| return { error: 'Bad Request' }; | ||
| }); | ||
|
|
||
| // Error that reaches the error handler with status still set to 200 (unusual, should still be captured) | ||
| app.get('/test-error-with-200-status', ({ set }) => { | ||
| set.status = 200; | ||
| throw new Error('Error with 200 status'); | ||
| }); | ||
|
|
||
| // POST route that echoes body | ||
| app.post('/test-post', ({ body }) => ({ status: 'ok', body })); | ||
|
|
||
| // Route that returns inbound headers (for propagation tests) | ||
| app.get('/test-inbound-headers/:id', ({ params, request }) => { | ||
| const headers = Object.fromEntries(request.headers.entries()); | ||
| return { headers, id: params.id }; | ||
| }); | ||
|
|
||
| // Outgoing fetch propagation | ||
| app.get('/test-outgoing-fetch/:id', async ({ params }) => { | ||
| const id = params.id; | ||
| const response = await fetch(`http://localhost:3030/test-inbound-headers/${id}`); | ||
| const data = await response.json(); | ||
| return data; | ||
| }); | ||
|
|
||
| // Outgoing fetch to external (allowed by tracePropagationTargets) | ||
| app.get('/test-outgoing-fetch-external-allowed', async () => { | ||
| const response = await fetch(`http://localhost:3040/external-allowed`); | ||
| const data = await response.json(); | ||
| return data; | ||
| }); | ||
|
|
||
| // Outgoing fetch to external (disallowed by tracePropagationTargets) | ||
| app.get('/test-outgoing-fetch-external-disallowed', async () => { | ||
| const response = await fetch(`http://localhost:3040/external-disallowed`); | ||
| const data = await response.json(); | ||
| return data; | ||
| }); | ||
|
|
||
| // Route that throws a string (not an Error object) | ||
| app.get('/test-string-error', () => { | ||
| // eslint-disable-next-line no-throw-literal | ||
| throw 'String error message'; | ||
| }); | ||
|
|
||
| // Route for concurrent isolation tests — returns scope data in response | ||
| app.get('/test-isolation/:userId', async ({ params }) => { | ||
| Sentry.setUser({ id: params.userId }); | ||
| Sentry.setTag('user_id', params.userId); | ||
|
|
||
| // Simulate async work to increase overlap between concurrent requests | ||
| await new Promise(resolve => setTimeout(resolve, 200)); | ||
|
|
||
| return { | ||
| userId: params.userId, | ||
| isolationScopeUserId: Sentry.getIsolationScope().getUser()?.id, | ||
| isolationScopeTag: Sentry.getIsolationScope().getScopeData().tags?.user_id, | ||
| }; | ||
| }); | ||
|
|
||
| // Flush route for waiting on events | ||
| app.get('/flush', async () => { | ||
| await Sentry.flush(); | ||
| return { ok: true }; | ||
| }); | ||
|
|
||
| app.listen(3030, () => { | ||
| console.log('Elysia app listening on port 3030'); | ||
| }); | ||
|
|
||
| // Second app for external propagation tests | ||
| const app2 = new Elysia(); | ||
|
|
||
| app2.get('/external-allowed', ({ request }) => { | ||
| const headers = Object.fromEntries(request.headers.entries()); | ||
| return { headers, route: '/external-allowed' }; | ||
| }); | ||
|
|
||
| app2.get('/external-disallowed', ({ request }) => { | ||
| const headers = Object.fromEntries(request.headers.entries()); | ||
| return { headers, route: '/external-disallowed' }; | ||
| }); | ||
|
|
||
| app2.listen(3040, () => { | ||
| console.log('External app listening on port 3040'); | ||
| }); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/elysia-bun/start-event-proxy.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { startEventProxyServer } from '@sentry-internal/test-utils'; | ||
|
|
||
| startEventProxyServer({ | ||
| port: 3031, | ||
| proxyServerName: 'elysia-bun', | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.