Skip to content

Commit ee7f39d

Browse files
mydeaclaude
andcommitted
ref(nestjs): Use @sentry/conventions
Source span/attribute keys from `@sentry/conventions` instead of the previous OpenTelemetry / vendored convention constants. No functional change. Includes the shared `vite/vite.config.ts` and `packages/typescript/tsconfig.json` infra changes needed for the vendored package across supported Node versions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent da5b10a commit ee7f39d

6 files changed

Lines changed: 29 additions & 4 deletions

File tree

packages/nestjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
"dependencies": {
4747
"@opentelemetry/api": "^1.9.1",
4848
"@opentelemetry/instrumentation": "^0.214.0",
49-
"@opentelemetry/semantic-conventions": "^1.40.0",
5049
"@sentry/core": "10.57.0",
5150
"@sentry/node": "10.57.0"
5251
},
5352
"devDependencies": {
5453
"@nestjs/common": "^10.0.0",
5554
"@nestjs/core": "^10.0.0",
55+
"@sentry/conventions": "^0.11.0",
5656
"reflect-metadata": "^0.2.2",
5757
"rxjs": "^7.8.2"
5858
},

packages/nestjs/rollup.npm.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,12 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu
33
export default makeNPMConfigVariants(
44
makeBaseNPMConfig({
55
entrypoints: ['src/index.ts', 'src/setup.ts'],
6+
packageSpecificConfig: {
7+
output: {
8+
// keep emitted module paths relative to `src` so the bundled `@sentry/conventions`
9+
// (a devDependency, vendored into the build) doesn't shift the output layout
10+
preserveModulesRoot: 'src',
11+
},
12+
},
613
}),
714
);

packages/nestjs/src/integrations/vendored/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
InstrumentationNodeModuleFile,
2727
isWrapped,
2828
} from '@opentelemetry/instrumentation';
29-
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
29+
import { HTTP_ROUTE } from '@sentry/conventions/attributes';
3030
import { SDK_VERSION } from '@sentry/core';
3131
import { AttributeNames, NestType } from './enums';
3232

@@ -174,7 +174,7 @@ function createWrapCreateHandler(tracer: api.Tracer, moduleVersion: string | und
174174
...NestInstrumentation.COMMON_ATTRIBUTES,
175175
[AttributeNames.VERSION]: moduleVersion,
176176
[AttributeNames.TYPE]: NestType.REQUEST_CONTEXT,
177-
[ATTR_HTTP_ROUTE]: req.route?.path || req.routeOptions?.url || req.routerPath,
177+
[HTTP_ROUTE]: req.route?.path || req.routeOptions?.url || req.routerPath,
178178
[AttributeNames.CONTROLLER]: instanceName,
179179
[AttributeNames.CALLBACK]: callbackName,
180180
};

packages/typescript/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"strict": true,
1919
"strictBindCallApply": false,
2020
"target": "es2020",
21-
"noUncheckedIndexedAccess": true
21+
"noUncheckedIndexedAccess": true,
22+
"paths": {
23+
"@sentry/conventions/attributes": ["../../node_modules/@sentry/conventions/dist/attributes"]
24+
}
2225
}
2326
}

vite/vite.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ export default defineConfig({
55
__DEBUG_BUILD__: true,
66
},
77
test: {
8+
server: {
9+
deps: {
10+
// `@sentry/conventions` is vendored into our build output (under `build/esm/node_modules/...`)
11+
// as ESM `.js` files. Vitest externalizes anything under a `node_modules/` path and loads it via
12+
// native `require`, which fails on Node 18 ("ES Module shipped in a CommonJS package") because
13+
// Node <20.19 can't `require()` ESM. Inlining makes Vitest transform it instead, so it works on
14+
// all supported Node versions. Production is unaffected (the package resolves via its exports map).
15+
inline: [/@sentry[/\\]conventions/],
16+
},
17+
},
818
coverage: {
919
enabled: true,
1020
reportsDirectory: './coverage',

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7578,6 +7578,11 @@
75787578
"@sentry/cli-win32-i686" "2.58.6"
75797579
"@sentry/cli-win32-x64" "2.58.6"
75807580

7581+
"@sentry/conventions@^0.11.0":
7582+
version "0.11.0"
7583+
resolved "https://registry.yarnpkg.com/@sentry/conventions/-/conventions-0.11.0.tgz#5a324b8368dc5c141260bd8ccc684756ea3dd843"
7584+
integrity sha512-AQTAKeq9mDpOElDFSPymZTPZF/c50rk355mWTf5Y1ZxZJKKOBli5qTttskJyCxrE5ynNgN1KwcXoU5MRrMSRmQ==
7585+
75817586
"@sentry/node-cpu-profiler@^2.4.2":
75827587
version "2.4.2"
75837588
resolved "https://registry.yarnpkg.com/@sentry/node-cpu-profiler/-/node-cpu-profiler-2.4.2.tgz#d0ba01370545297d015df1497daf7f81e27f2ab5"

0 commit comments

Comments
 (0)