Skip to content

Commit 8d64ae5

Browse files
committed
fixes and stuff
1 parent 376c050 commit 8d64ae5

27 files changed

Lines changed: 179 additions & 429 deletions

dev-packages/e2e-tests/test-applications/remix-orchestrion/app/routes/db-ioredis.tsx renamed to dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/routes/db-ioredis.tsx

File renamed without changes.

dev-packages/e2e-tests/test-applications/remix-orchestrion/app/routes/db-mysql.tsx renamed to dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/routes/db-mysql.tsx

File renamed without changes.

dev-packages/e2e-tests/test-applications/remix-orchestrion/docker-compose.yml renamed to dev-packages/e2e-tests/test-applications/create-remix-app-v2/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
db:
33
image: mysql:8.0
44
restart: always
5-
container_name: e2e-tests-remix-orchestrion-mysql
5+
container_name: e2e-tests-create-remix-app-v2-mysql
66
# The `mysql` 2.x driver doesn't speak MySQL 8's default
77
# `caching_sha2_password` auth, so force the legacy plugin.
88
command: ['--default-authentication-plugin=mysql_native_password']
@@ -20,7 +20,7 @@ services:
2020
redis:
2121
image: redis:7
2222
restart: always
23-
container_name: e2e-tests-remix-orchestrion-redis
23+
container_name: e2e-tests-create-remix-app-v2-redis
2424
ports:
2525
- '6379:6379'
2626
healthcheck:

dev-packages/e2e-tests/test-applications/remix-orchestrion/global-setup.mjs renamed to dev-packages/e2e-tests/test-applications/create-remix-app-v2/global-setup.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default async function globalSetup() {
1313
// recognize a leftover container from a previous (e.g. interrupted) run as
1414
// part of the same project - but the container names are fixed, so the daemon
1515
// still refuses to create new ones. Force-remove any stale leftovers first.
16-
for (const container of ['e2e-tests-remix-orchestrion-mysql', 'e2e-tests-remix-orchestrion-redis']) {
16+
for (const container of ['e2e-tests-create-remix-app-v2-mysql', 'e2e-tests-create-remix-app-v2-redis']) {
1717
try {
1818
execSync(`docker rm -f ${container}`, { stdio: 'ignore' });
1919
} catch {

dev-packages/e2e-tests/test-applications/remix-orchestrion/global-teardown.mjs renamed to dev-packages/e2e-tests/test-applications/create-remix-app-v2/global-teardown.mjs

File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
const Sentry = require('@sentry/remix');
22

3+
const injectOrchestrion = process.env.INJECT_ORCHESTRION === 'true';
4+
5+
if (injectOrchestrion) {
6+
// Opt into diagnostics-channel-based auto-instrumentation. This registers the
7+
// channel subscribers (e.g. for mysql and ioredis) that turn the
8+
// diagnostics-channel events - injected at build time by the orchestrion Vite
9+
// plugin (see vite.config.ts) - into Sentry spans. Must run before Sentry.init().
10+
Sentry.experimentalUseDiagnosticsChannelInjection();
11+
}
12+
313
Sentry.init({
414
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
515
environment: 'qa', // dynamic sampling bias to keep transactions
616
dsn: process.env.E2E_TEST_DSN,
717
tunnel: 'http://localhost:3031/', // proxy server
18+
// In the orchestrion variant, the channel-based Remix integration replaces the default
19+
// OpenTelemetry one (same `Remix` name, so it overwrites the default).
20+
integrations: injectOrchestrion ? [Sentry.remixChannelIntegration()] : [],
821
});

dev-packages/e2e-tests/test-applications/create-remix-app-v2/package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
{
22
"private": true,
33
"sideEffects": false,
4+
"type": "module",
45
"scripts": {
56
"build": "remix vite:build && pnpm typecheck",
67
"dev": "remix vite:dev",
78
"start": "NODE_OPTIONS='--require=./instrument.server.cjs' remix-serve build/server/index.js",
89
"typecheck": "tsc",
910
"clean": "npx rimraf node_modules pnpm-lock.yaml",
1011
"test:build": "pnpm install && pnpm build",
11-
"test:assert": "pnpm playwright test"
12+
"test:assert": "pnpm playwright test",
13+
"test:build:orchestrion": "INJECT_ORCHESTRION=true pnpm test:build",
14+
"test:assert:orchestrion": "INJECT_ORCHESTRION=true pnpm test:assert"
1215
},
1316
"dependencies": {
1417
"@sentry/remix": "file:../../packed/sentry-remix-packed.tgz",
18+
"@sentry/server-utils": "file:../../packed/sentry-server-utils-packed.tgz",
1519
"@remix-run/css-bundle": "2.17.4",
1620
"@remix-run/node": "2.17.4",
1721
"@remix-run/react": "2.17.4",
1822
"@remix-run/serve": "2.17.4",
1923
"isbot": "^3.6.8",
24+
"ioredis": "5.10.1",
25+
"mysql": "^2.18.1",
2026
"react": "^18.2.0",
2127
"react-dom": "^18.2.0"
2228
},
@@ -25,6 +31,7 @@
2531
"@sentry-internal/test-utils": "link:../../../test-utils",
2632
"@remix-run/dev": "2.17.4",
2733
"@remix-run/eslint-config": "2.17.4",
34+
"@types/mysql": "^2.15.26",
2835
"@types/react": "^18.2.64",
2936
"@types/react-dom": "^18.2.34",
3037
"@types/prop-types": "15.7.7",
@@ -36,6 +43,15 @@
3643
"resolutions": {
3744
"@types/react": "18.2.22"
3845
},
46+
"sentryTest": {
47+
"variants": [
48+
{
49+
"build-command": "pnpm test:build:orchestrion",
50+
"assert-command": "pnpm test:assert:orchestrion",
51+
"label": "create-remix-app-v2 (orchestrion)"
52+
}
53+
]
54+
},
3955
"volta": {
4056
"extends": "../../package.json"
4157
}
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
import { fileURLToPath } from 'url';
23

3-
const config = getPlaywrightConfig({
4-
startCommand: `pnpm start`,
5-
});
4+
const injectOrchestrion = process.env.INJECT_ORCHESTRION === 'true';
5+
6+
const config = getPlaywrightConfig(
7+
{
8+
startCommand: `pnpm start`,
9+
},
10+
// The orchestrion variant exercises real MySQL/Redis. Boot them before the tests run,
11+
// outside the webServer startup-timeout window. In the default variant no DB is needed.
12+
injectOrchestrion
13+
? {
14+
globalSetup: fileURLToPath(new URL('./global-setup.mjs', import.meta.url)),
15+
globalTeardown: fileURLToPath(new URL('./global-teardown.mjs', import.meta.url)),
16+
}
17+
: {},
18+
);
619

720
export default config;

dev-packages/e2e-tests/test-applications/create-remix-app-v2/remix.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/remix-orchestrion/tests/build-injection.test.ts renamed to dev-packages/e2e-tests/test-applications/create-remix-app-v2/tests/build-injection.test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ import { expect, test } from '@playwright/test';
44

55
// The `db.test.ts` runtime assertions prove orchestrion spans appear, but spans alone
66
// don't prove they came from the BUILD-time transform: if the Vite plugin silently
7-
// failed to load, the deps would stay external and the runtime `--import` hook would
7+
// failed to load, the deps would stay external and the runtime `--require` hook would
88
// inject the channels at runtime instead - the span tests would still pass. These
99
// assertions inspect the built server bundle directly so a broken plugin can't hide
10-
// behind that runtime fallback.
10+
// behind that runtime fallback. Only relevant in the orchestrion variant.
1111
test.describe('orchestrion build-time injection', () => {
12+
test.skip(process.env.INJECT_ORCHESTRION !== 'true', 'Only runs in the orchestrion variant');
13+
1214
const serverBundle = readFileSync(path.join(process.cwd(), 'build/server/index.js'), 'utf8');
1315

1416
test('force-bundles the instrumented deps instead of externalizing them', () => {
1517
// The plugin adds mysql/ioredis to `ssr.noExternal` so the transform sees their
16-
// source. Without it they'd be left as bare imports (this is an ESM server build)
17-
// or `require(...)` calls resolved from node_modules at runtime - untouched, with
18-
// no channels injected.
18+
// source. Without it they'd be left as bare imports or `require(...)` calls resolved
19+
// from node_modules at runtime - untouched, with no channels injected.
1920
expect(serverBundle).not.toMatch(/(from\s*["']mysql["']|require\(["']mysql["']\))/);
2021
expect(serverBundle).not.toMatch(/(from\s*["']ioredis["']|require\(["']ioredis["']\))/);
2122
});
@@ -25,8 +26,20 @@ test.describe('orchestrion build-time injection', () => {
2526
// publisher whose channel name is a string literal. The subscriber side passes the
2627
// channel name as a variable, so a literal-arg match is unique to the injected
2728
// publisher and proves the build-time transform ran.
28-
expect(serverBundle).toMatch(/tracingChannel\(["']orchestrion:mysql:query["']\)/);
29-
expect(serverBundle).toMatch(/tracingChannel\(["']orchestrion:ioredis:command["']\)/);
30-
expect(serverBundle).toMatch(/tracingChannel\(["']orchestrion:ioredis:connect["']\)/);
29+
expect(serverBundle).toMatch(/tracingChannel(\$?\d)?\(["']orchestrion:mysql:query["']\)/);
30+
expect(serverBundle).toMatch(/tracingChannel(\$?\d)?\(["']orchestrion:ioredis:command["']\)/);
31+
expect(serverBundle).toMatch(/tracingChannel(\$?\d)?\(["']orchestrion:ioredis:connect["']\)/);
32+
});
33+
34+
test('injects the diagnostics-channel publishers into @remix-run/server-runtime', () => {
35+
// Remix's own instrumentation is orchestrion-based too: the transform force-bundles
36+
// and injects channels into `@remix-run/server-runtime` (the subscriber is
37+
// `remixChannelIntegration`).
38+
expect(serverBundle).toMatch(
39+
/tracingChannel(\$?\d)?\(["']orchestrion:@remix-run\/server-runtime:requestHandler["']\)/,
40+
);
41+
expect(serverBundle).toMatch(
42+
/tracingChannel(\$?\d)?\(["']orchestrion:@remix-run\/server-runtime:callRouteLoader["']\)/,
43+
);
3144
});
3245
});

0 commit comments

Comments
 (0)