-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(nuxt)!: Enable orchestrion instrumentation on Cloudflare #23015
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
chargome
wants to merge
2
commits into
develop
Choose a base branch
from
charlygomez/js-3205-nuxt-cloudflare-orchestrion
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.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
5 changes: 5 additions & 0 deletions
5
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/app/app.vue
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,5 @@ | ||
| <template> | ||
| <div> | ||
| <h1>Nuxt on Cloudflare</h1> | ||
| </div> | ||
| </template> |
18 changes: 18 additions & 0 deletions
18
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/docker-compose.yml
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,18 @@ | ||
| services: | ||
| db: | ||
| image: mysql:8.0 | ||
| restart: always | ||
| container_name: e2e-tests-nuxt-4-cloudflare-mysql | ||
| # The `mysql` 2.x driver doesn't speak MySQL 8's default | ||
| # `caching_sha2_password` auth, so force the legacy plugin. | ||
| command: ['--default-authentication-plugin=mysql_native_password'] | ||
| ports: | ||
| - '3306:3306' | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: docker | ||
| healthcheck: | ||
| test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 -uroot -pdocker'] | ||
| interval: 2s | ||
| timeout: 3s | ||
| retries: 30 | ||
| start_period: 10s |
14 changes: 14 additions & 0 deletions
14
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/global-setup.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,14 @@ | ||
| import { execSync } from 'child_process'; | ||
| import { dirname } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| export default async function globalSetup() { | ||
| // Start MySQL via Docker Compose. `--wait` blocks until the healthcheck in | ||
| // docker-compose.yml passes, so the worker can connect on the first request. | ||
| execSync('docker compose up -d --wait', { | ||
| cwd: __dirname, | ||
| stdio: 'inherit', | ||
| }); | ||
| } |
12 changes: 12 additions & 0 deletions
12
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/global-teardown.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,12 @@ | ||
| import { execSync } from 'child_process'; | ||
| import { dirname } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| export default async function globalTeardown() { | ||
| execSync('docker compose down --volumes', { | ||
| cwd: __dirname, | ||
| stdio: 'inherit', | ||
| }); | ||
| } |
18 changes: 18 additions & 0 deletions
18
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/nuxt.config.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,18 @@ | ||
| // https://nuxt.com/docs/api/configuration/nuxt-config | ||
| export default defineNuxtConfig({ | ||
| compatibilityDate: '2025-06-06', | ||
| modules: ['@sentry/nuxt/module'], | ||
| nitro: { | ||
| preset: 'cloudflare_module', | ||
| cloudflare: { | ||
| nodeCompat: true, | ||
| deployConfig: false, | ||
| }, | ||
| // The bundled `mysql` driver pulls in `readable-stream`, whose base `require('stream')` has no | ||
| // usable prototype under Nitro's unenv polyfill (throws `superCtor.prototype ... undefined`). | ||
| // Alias it to workerd's native `node:stream`, which has a real `Readable`. | ||
| alias: { | ||
| 'readable-stream': 'node:stream', | ||
| }, | ||
| }, | ||
| }); |
28 changes: 28 additions & 0 deletions
28
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/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,28 @@ | ||
| { | ||
| "name": "nuxt-4-cloudflare", | ||
| "type": "module", | ||
| "private": true, | ||
| "scripts": { | ||
| "build": "nuxt build", | ||
| "dev": "nuxt dev", | ||
| "preview": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --port 3030 --log-level=$(test $CI && echo 'none' || echo 'log')", | ||
| "test": "playwright test", | ||
| "test:build": "pnpm install && pnpm build", | ||
| "test:assert": "pnpm test" | ||
| }, | ||
| "dependencies": { | ||
| "@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz", | ||
| "@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz", | ||
| "mysql": "2.18.1", | ||
| "nuxt": "^4.1.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@playwright/test": "~1.56.0", | ||
| "@sentry-internal/test-utils": "link:../../../test-utils", | ||
| "wrangler": "^4.72.0" | ||
| }, | ||
| "volta": { | ||
| "node": "22.20.0", | ||
| "extends": "../../package.json" | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/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,17 @@ | ||
| import { getPlaywrightConfig } from '@sentry-internal/test-utils'; | ||
|
|
||
| // `nuxt build` (where the Sentry Nuxt module's orchestrion transform runs over Nitro's Cloudflare | ||
| // preset) produces the worker; `pnpm preview` (`wrangler dev`) serves it. `globalSetup` spins up the | ||
| // MySQL container the worker connects to. | ||
| const config = getPlaywrightConfig( | ||
| { | ||
| startCommand: 'pnpm preview', | ||
| port: 3030, | ||
| }, | ||
| { | ||
| globalSetup: './global-setup.mjs', | ||
| globalTeardown: './global-teardown.mjs', | ||
| }, | ||
| ); | ||
|
|
||
| export default config; |
35 changes: 35 additions & 0 deletions
35
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/api/db-mysql.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,35 @@ | ||
| import { defineEventHandler } from '#imports'; | ||
| import mysql from 'mysql'; | ||
|
|
||
| export default defineEventHandler(() => { | ||
| const connection = mysql.createConnection({ | ||
| host: '127.0.0.1', | ||
| port: 3306, | ||
| user: 'root', | ||
| password: 'docker', | ||
| }); | ||
|
|
||
| connection.on('error', () => { | ||
| // no-op | ||
| }); | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| connection.query('SELECT 1 + 1 AS solution', error => { | ||
| if (error) { | ||
| connection.end(); | ||
| reject(error); | ||
| return; | ||
| } | ||
|
|
||
| connection.query('SELECT NOW()', nestedError => { | ||
| connection.end(); | ||
| if (nestedError) { | ||
| reject(nestedError); | ||
| return; | ||
| } | ||
|
|
||
| resolve({ status: 'ok' }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
11 changes: 11 additions & 0 deletions
11
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/server/plugins/sentry.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,11 @@ | ||
| import { defineNitroPlugin } from '#imports'; | ||
| import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins'; | ||
|
|
||
| export default defineNitroPlugin( | ||
| sentryCloudflareNitroPlugin({ | ||
| traceLifecycle: 'static', | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| tracesSampleRate: 1.0, | ||
| tunnel: 'http://localhost:3031/', // proxy server | ||
| }), | ||
| ); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/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: 'nuxt-4-cloudflare', | ||
| }); |
43 changes: 43 additions & 0 deletions
43
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tests/db.test.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,43 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
|
||
| test('a real mysql query emits a db span with orchestrion-channel attributes', async ({ request }) => { | ||
| const transactionPromise = waitForTransaction('nuxt-4-cloudflare', transactionEvent => { | ||
| return ( | ||
| transactionEvent.contexts?.trace?.op === 'http.server' && | ||
| (transactionEvent.spans?.some(span => span.op === 'db') ?? false) | ||
| ); | ||
| }); | ||
|
|
||
| const res = await request.get('/api/db-mysql'); | ||
| expect(res.status()).toBe(200); | ||
|
|
||
| const transactionEvent = await transactionPromise; | ||
| const dbSpans = transactionEvent.spans!.filter(span => span.op === 'db'); | ||
|
|
||
| const firstQuery = dbSpans.find(span => span.description === 'SELECT 1 + 1 AS solution'); | ||
| expect(firstQuery).toBeDefined(); | ||
| expect(firstQuery!.data?.['sentry.origin']).toBe('auto.db.mysql'); | ||
| expect(firstQuery!.data?.['db.system']).toBe('mysql'); | ||
| expect(firstQuery!.data?.['db.statement']).toBe('SELECT 1 + 1 AS solution'); | ||
| expect(firstQuery!.data?.['net.peer.name']).toBe('127.0.0.1'); | ||
| expect(firstQuery!.data?.['net.peer.port']).toBe(3306); | ||
| expect(firstQuery!.data?.['db.user']).toBe('root'); | ||
| }); | ||
|
|
||
| test('a nested query lands on the same transaction (async context restored)', async ({ request }) => { | ||
| const transactionPromise = waitForTransaction('nuxt-4-cloudflare', transactionEvent => { | ||
| return ( | ||
| transactionEvent.contexts?.trace?.op === 'http.server' && | ||
| (transactionEvent.spans?.filter(span => span.op === 'db').length ?? 0) >= 2 | ||
| ); | ||
| }); | ||
|
|
||
| const res = await request.get('/api/db-mysql'); | ||
| expect(res.status()).toBe(200); | ||
|
|
||
| const transactionEvent = await transactionPromise; | ||
| const descriptions = transactionEvent.spans!.filter(span => span.op === 'db').map(span => span.description); | ||
| expect(descriptions).toContain('SELECT 1 + 1 AS solution'); | ||
| expect(descriptions).toContain('SELECT NOW()'); | ||
| }); |
4 changes: 4 additions & 0 deletions
4
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/tsconfig.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,4 @@ | ||
| { | ||
| // https://nuxt.com/docs/guide/concepts/typescript | ||
| "extends": "./.nuxt/tsconfig.json" | ||
| } |
11 changes: 11 additions & 0 deletions
11
dev-packages/e2e-tests/test-applications/nuxt-4-cloudflare/wrangler.jsonc
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,11 @@ | ||
| { | ||
| "$schema": "node_modules/wrangler/config-schema.json", | ||
| "name": "nuxt-4-cloudflare", | ||
| "main": "./.output/server/index.mjs", | ||
| "compatibility_date": "2026-06-29", | ||
| "compatibility_flags": ["nodejs_compat"], | ||
| "assets": { | ||
| "directory": "./.output/public", | ||
| "binding": "ASSETS", | ||
| }, | ||
| } |
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
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.