Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"mysql": "^2.18.1"
},
"devDependencies": {
"@apm-js-collab/code-transformer-bundler-plugins": "^0.5.0"
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.0"
},
"volta": {
"node": "22.22.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"vue-router": "^5.1.0"
},
"devDependencies": {
"@apm-js-collab/code-transformer-bundler-plugins": "^0.5.0",
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.0",
"@playwright/test": "~1.56.0",
"@sentry-internal/test-utils": "link:../../../test-utils"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"mysql": "^2.18.1"
},
"devDependencies": {
"@apm-js-collab/code-transformer-bundler-plugins": "^0.5.0",
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.0",
"@playwright/test": "~1.56.0",
"@sentry-internal/test-utils": "link:../../../test-utils",
"@sveltejs/adapter-auto": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"access": "public"
},
"dependencies": {
"@apm-js-collab/code-transformer-bundler-plugins": "^0.6.1",
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.0",
"@sentry/core": "10.66.0",
"@sentry/node": "10.66.0",
"@sentry/server-utils": "10.66.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/server-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"access": "public"
},
"dependencies": {
"@apm-js-collab/code-transformer-bundler-plugins": "^0.6.1",
"@apm-js-collab/code-transformer-bundler-plugins": "^0.7.0",
"@apm-js-collab/code-transformer": "^0.18.0",
"@apm-js-collab/tracing-hooks": "^0.13.0",
"@sentry/conventions": "^0.16.0",
Expand Down
29 changes: 25 additions & 4 deletions packages/server-utils/src/orchestrion/bundler/options.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';
import type { InstrumentationConfig, CustomTransform } from '@apm-js-collab/code-transformer';
import { SENTRY_INSTRUMENTATIONS } from '../config';
import type codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/rollup';
import type { CodeTransformerPluginOptions } from '@apm-js-collab/code-transformer-bundler-plugins/core';

export type PluginOptions = {
/**
* Additional instrumentations to include with the default instrumentation.
*/
instrumentations?: InstrumentationConfig[];
/**
* Custom transforms that can be applied using the `transform` option in each `InstrumentationConfig`.
*/
customTransforms?: Record<string, CustomTransform>;
/**
* Whether to inject the global diagnostics.
*
* Defaults to `true`.
*/
shouldInjectDiagnostics?: boolean;
Comment thread
timfish marked this conversation as resolved.
};

/**
Expand All @@ -18,9 +28,20 @@ export type PluginOptions = {
* bundler path ran (rather than relying on a build-time flag that wouldn't be
* visible to the runtime).
*/
export function orchestrionTransformOptions(options: PluginOptions): Parameters<typeof codeTransformer>[0] {
export function orchestrionTransformOptions(options: PluginOptions): CodeTransformerPluginOptions {
const instrumentations = [...SENTRY_INSTRUMENTATIONS, ...(options.instrumentations || [])];
const customTransforms = options.customTransforms;

if (options.shouldInjectDiagnostics === false) {
return {
instrumentations,
customTransforms,
};
}

return {
instrumentations: [...SENTRY_INSTRUMENTATIONS, ...(options.instrumentations || [])],
instrumentations,
customTransforms,
injectDiagnostics: (diag: { transformedModules: string[]; failedModules: string[] }) => {
return `(globalThis.__SENTRY_ORCHESTRION__=globalThis.__SENTRY_ORCHESTRION__||{}).bundler=${JSON.stringify(diag.transformedModules)};`;
},
Expand Down
10 changes: 5 additions & 5 deletions packages/server-utils/src/orchestrion/bundler/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import type { InstrumentationConfig } from '@apm-js-collab/code-transformer';
import { SENTRY_INSTRUMENTATIONS } from '../config';
import type { PluginOptions } from './options';
import { orchestrionTransformOptions } from './options';

// Both branches use `createRequire` (never alias the CJS `require`) so bundlers consuming this
// module don't emit a "Critical dependency" warning.
Expand Down Expand Up @@ -42,14 +44,12 @@ export function getSentryInstrumentations(): InstrumentationConfig[] {
}

/**
* The code-transform webpack plugin, pre-fed the instrumentation config. Unlike the Vite plugin it
* does NOT inject the `__SENTRY_ORCHESTRION__.bundler` marker — that would disable the runtime
* module hook, which externalized packages still need (hybrid setup).
* The code-transform webpack plugin, pre-fed the instrumentation config
*/
export function sentryOrchestrionWebpackPlugin(): unknown {
export function sentryOrchestrionWebpackPlugin(options: PluginOptions = {}): unknown {
const mod = getOrchestrionRequire()('@apm-js-collab/code-transformer-bundler-plugins/webpack') as {
default?: (options: { instrumentations: InstrumentationConfig[] }) => unknown;
};
const codeTransformerWebpack = mod.default ?? (mod as unknown as NonNullable<typeof mod.default>);
return codeTransformerWebpack({ instrumentations: SENTRY_INSTRUMENTATIONS });
return codeTransformerWebpack(orchestrionTransformOptions(options));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Webpack injects diagnostics by default

Medium Severity

sentryOrchestrionWebpackPlugin() now passes orchestrionTransformOptions, which enables injectDiagnostics by default. That sets globalThis.__SENTRY_ORCHESTRION__ before Sentry.init, so integrations like Knex treat orchestrion as active and skip OpenTelemetry even when the runtime hook was never registered and external packages were not transformed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 074639c. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is fine now we've removed the runtime skipping

}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@
dependencies:
json-schema-to-ts "^3.1.1"

"@apm-js-collab/code-transformer-bundler-plugins@^0.6.1":
version "0.6.1"
resolved "https://registry.yarnpkg.com/@apm-js-collab/code-transformer-bundler-plugins/-/code-transformer-bundler-plugins-0.6.1.tgz#29bf79167411b8607f02db177250b8f7c16d93e1"
integrity sha512-TDvypsLUk/W202Y1JBE6I2enQalWjbYXKnxpELWEZn6GLoIcGFii69ljh948hdAzKZJ/wg0Uwivz72a/szoOBQ==
"@apm-js-collab/code-transformer-bundler-plugins@^0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@apm-js-collab/code-transformer-bundler-plugins/-/code-transformer-bundler-plugins-0.7.0.tgz#499cb4730570e4f4bc3a1e77739dc1fb17839a7a"
integrity sha512-huqdbQqE1lTUM2uud/qBY664o5qGPLrI/3ipGRNcTP37otpaVOb6omfIU/8QyR4aObhkpgnFl0ywtoAJZ+y2jw==
dependencies:
"@apm-js-collab/code-transformer" "^0.18.0"
es-module-lexer "^2.1.0"
Expand Down
Loading