From 3c34348e05f148a976d384ed248d887ad0372b49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 19:03:33 +0000 Subject: [PATCH 1/5] Bump the build group with 2 updates Bumps the build group with 2 updates: [typescript](https://github.com/Microsoft/TypeScript) and [rollup](https://github.com/rollup/rollup). Updates `typescript` from 5.2.2 to 5.3.2 - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/commits) Updates `rollup` from 4.4.0 to 4.5.0 - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.4.0...v4.5.0) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor dependency-group: build - dependency-name: rollup dependency-type: direct:development update-type: version-update:semver-minor dependency-group: build ... Signed-off-by: dependabot[bot] --- yarn.lock | 116 +++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/yarn.lock b/yarn.lock index cc9f2118..096daabf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1634,86 +1634,86 @@ __metadata: languageName: node linkType: hard -"@rollup/rollup-android-arm-eabi@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-android-arm-eabi@npm:4.4.0" +"@rollup/rollup-android-arm-eabi@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.5.0" conditions: os=android & cpu=arm languageName: node linkType: hard -"@rollup/rollup-android-arm64@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-android-arm64@npm:4.4.0" +"@rollup/rollup-android-arm64@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-android-arm64@npm:4.5.0" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-arm64@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-darwin-arm64@npm:4.4.0" +"@rollup/rollup-darwin-arm64@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-darwin-arm64@npm:4.5.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-darwin-x64@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-darwin-x64@npm:4.4.0" +"@rollup/rollup-darwin-x64@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-darwin-x64@npm:4.5.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@rollup/rollup-linux-arm-gnueabihf@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.4.0" +"@rollup/rollup-linux-arm-gnueabihf@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.5.0" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@rollup/rollup-linux-arm64-gnu@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.4.0" +"@rollup/rollup-linux-arm64-gnu@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.5.0" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-arm64-musl@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-linux-arm64-musl@npm:4.4.0" +"@rollup/rollup-linux-arm64-musl@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.5.0" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-linux-x64-gnu@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-linux-x64-gnu@npm:4.4.0" +"@rollup/rollup-linux-x64-gnu@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.5.0" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@rollup/rollup-linux-x64-musl@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-linux-x64-musl@npm:4.4.0" +"@rollup/rollup-linux-x64-musl@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.5.0" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@rollup/rollup-win32-arm64-msvc@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.4.0" +"@rollup/rollup-win32-arm64-msvc@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.5.0" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@rollup/rollup-win32-ia32-msvc@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.4.0" +"@rollup/rollup-win32-ia32-msvc@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.5.0" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@rollup/rollup-win32-x64-msvc@npm:4.4.0": - version: 4.4.0 - resolution: "@rollup/rollup-win32-x64-msvc@npm:4.4.0" +"@rollup/rollup-win32-x64-msvc@npm:4.5.0": + version: 4.5.0 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.5.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -6902,21 +6902,21 @@ __metadata: linkType: hard "rollup@npm:^4.3.0": - version: 4.4.0 - resolution: "rollup@npm:4.4.0" - dependencies: - "@rollup/rollup-android-arm-eabi": "npm:4.4.0" - "@rollup/rollup-android-arm64": "npm:4.4.0" - "@rollup/rollup-darwin-arm64": "npm:4.4.0" - "@rollup/rollup-darwin-x64": "npm:4.4.0" - "@rollup/rollup-linux-arm-gnueabihf": "npm:4.4.0" - "@rollup/rollup-linux-arm64-gnu": "npm:4.4.0" - "@rollup/rollup-linux-arm64-musl": "npm:4.4.0" - "@rollup/rollup-linux-x64-gnu": "npm:4.4.0" - "@rollup/rollup-linux-x64-musl": "npm:4.4.0" - "@rollup/rollup-win32-arm64-msvc": "npm:4.4.0" - "@rollup/rollup-win32-ia32-msvc": "npm:4.4.0" - "@rollup/rollup-win32-x64-msvc": "npm:4.4.0" + version: 4.5.0 + resolution: "rollup@npm:4.5.0" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.5.0" + "@rollup/rollup-android-arm64": "npm:4.5.0" + "@rollup/rollup-darwin-arm64": "npm:4.5.0" + "@rollup/rollup-darwin-x64": "npm:4.5.0" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.5.0" + "@rollup/rollup-linux-arm64-gnu": "npm:4.5.0" + "@rollup/rollup-linux-arm64-musl": "npm:4.5.0" + "@rollup/rollup-linux-x64-gnu": "npm:4.5.0" + "@rollup/rollup-linux-x64-musl": "npm:4.5.0" + "@rollup/rollup-win32-arm64-msvc": "npm:4.5.0" + "@rollup/rollup-win32-ia32-msvc": "npm:4.5.0" + "@rollup/rollup-win32-x64-msvc": "npm:4.5.0" fsevents: "npm:~2.3.2" dependenciesMeta: "@rollup/rollup-android-arm-eabi": @@ -6947,7 +6947,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: 69e4f48f563af4ad209fe1b7e6fb3f280abbe7e8a331d246a594936c16ed39d49d62f4bce26a465750d92e86accc68c3a507bcd93b92f87f335ecaaac4597391 + checksum: baed6dade46ea34d051eb27fc33626638b1386389887d0ff42e922d9c31f1befc2d56b96024112ddd3d63bd9bdbcafa461982d857689752f286f5968669e2924 languageName: node linkType: hard @@ -7793,22 +7793,22 @@ __metadata: linkType: hard "typescript@npm:^5.2.2": - version: 5.2.2 - resolution: "typescript@npm:5.2.2" + version: 5.3.2 + resolution: "typescript@npm:5.3.2" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 91ae3e6193d0ddb8656d4c418a033f0f75dec5e077ebbc2bd6d76439b93f35683936ee1bdc0e9cf94ec76863aa49f27159b5788219b50e1cd0cd6d110aa34b07 + checksum: d7dbe1fbe19039e36a65468ea64b5d338c976550394ba576b7af9c68ed40c0bc5d12ecce390e4b94b287a09a71bd3229f19c2d5680611f35b7c53a3898791159 languageName: node linkType: hard "typescript@patch:typescript@npm%3A^5.2.2#optional!builtin": - version: 5.2.2 - resolution: "typescript@patch:typescript@npm%3A5.2.2#optional!builtin::version=5.2.2&hash=f3b441" + version: 5.3.2 + resolution: "typescript@patch:typescript@npm%3A5.3.2#optional!builtin::version=5.3.2&hash=e012d7" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 062c1cee1990e6b9419ce8a55162b8dc917eb87f807e4de0327dbc1c2fa4e5f61bc0dd4e034d38ff541d1ed0479b53bcee8e4de3a4075c51a1724eb6216cb6f5 + checksum: 73c8bad74e732d93211c9d77f28b03307e2f5fc6a0afc73f4b783261ab567686a16d6ae958bdaef383a00be1b0b8c8b6741dd6ca3d13af4963fa7e47456d49c7 languageName: node linkType: hard From 2f0aeb5c53c493495e5e73e2955ebabb920adff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Mon, 20 Nov 2023 14:13:46 -0800 Subject: [PATCH 2/5] fix build errors --- packages/compat/package.json | 3 --- packages/compat/src/index.ts | 19 ++++++++----------- yarn.lock | 1 - 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/compat/package.json b/packages/compat/package.json index a7958e8e..1a73ae82 100644 --- a/packages/compat/package.json +++ b/packages/compat/package.json @@ -35,9 +35,6 @@ "publish": "node ../../scripts/publish.js", "test": "swtest -p test/tsconfig.json -c src" }, - "dependencies": { - "@opentelemetry/semantic-conventions": "~1.18.1" - }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" }, diff --git a/packages/compat/src/index.ts b/packages/compat/src/index.ts index e1a63777..339b6a60 100644 --- a/packages/compat/src/index.ts +++ b/packages/compat/src/index.ts @@ -21,13 +21,11 @@ import { SpanStatusCode, trace, } from "@opentelemetry/api" -import { SemanticAttributes } from "@opentelemetry/semantic-conventions" import packageJson from "../package.json" interface InstrumentOptions { enabled?: boolean - collectBacktraces?: boolean } interface SpanInfo { @@ -50,25 +48,24 @@ function startActiveSpan(span: SpanOptions, f: (span: Span) => T): T { }) } -function setError(span: Span, options: InstrumentOptions, err: unknown) { +function setError(span: Span, err: unknown) { const status: SpanStatus = { code: SpanStatusCode.ERROR } if (err instanceof Error) { + span.recordException(err) status.message = err.message - if (options.collectBacktraces !== false && err.stack) { - span.setAttribute(SemanticAttributes.EXCEPTION_STACKTRACE, err.stack) - } + } else { + span.recordException(String(err)) } span.setStatus(status) } function makeDone( span: Span, - options: InstrumentOptions, cb: AsyncCallback, ): AsyncCallback { return (...args) => { if (args[0] instanceof Error) { - setError(span, options, args[0]) + setError(span, args[0]) } const r = cb(...args) @@ -114,11 +111,11 @@ export function instrument( } return startActiveSpan(span, (span) => { - const done = makeDone(span, o, cb) + const done = makeDone(span, cb) try { return run(done) } catch (err) { - setError(span, o, err) + setError(span, err) throw err } finally { if (run.length === 0) { @@ -141,7 +138,7 @@ export function pInstrument( try { return await run() } catch (err) { - setError(span, options ?? {}, err) + setError(span, err) throw err } finally { span.end() diff --git a/yarn.lock b/yarn.lock index 096daabf..c4473e38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1826,7 +1826,6 @@ __metadata: "@opentelemetry/api": "npm:^1.3.0" "@opentelemetry/sdk-trace-base": "npm:~1.18.1" "@opentelemetry/sdk-trace-node": "npm:~1.18.1" - "@opentelemetry/semantic-conventions": "npm:~1.18.1" "@solarwinds-apm/eslint-config": "workspace:^" "@solarwinds-apm/rollup-config": "workspace:^" "@solarwinds-apm/test": "workspace:^" From 75c80f9b016ca30624cc7f8bda5b1f6f2f93f9af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Mon, 20 Nov 2023 14:16:30 -0800 Subject: [PATCH 3/5] fix old test --- packages/compat/test/index.test.ts | 57 ------------------------------ 1 file changed, 57 deletions(-) diff --git a/packages/compat/test/index.test.ts b/packages/compat/test/index.test.ts index 168415e8..b99f21e8 100644 --- a/packages/compat/test/index.test.ts +++ b/packages/compat/test/index.test.ts @@ -111,34 +111,6 @@ describe("instrument", () => { ) }) - it("doesn't collect backtraces if explicitly disabled", async () => { - await inParent(() => { - let error: unknown = undefined - try { - instrument( - "child", - () => { - throw new Error("error") - }, - { collectBacktraces: false }, - ) - } catch (e) { - error = e - } - expect(error).to.be.an.instanceof(Error) - }) - - const span = exporter.getFinishedSpans()[0] - expect(span?.name).to.equal("child") - expect(span?.status).to.include({ - code: SpanStatusCode.ERROR, - message: "error", - }) - expect(span?.attributes).not.to.have.property( - SemanticAttributes.EXCEPTION_STACKTRACE, - ) - }) - it("instruments callback code", async () => { await inParent( () => @@ -279,33 +251,4 @@ describe("pInstrument", () => { SemanticAttributes.EXCEPTION_STACKTRACE, ) }) - - it("doesn't collect backtraces if explicitly disabled", async () => { - await inParent(async () => { - let error: unknown = undefined - try { - await pInstrument( - "child", - async () => { - await Promise.resolve() - throw new Error("error") - }, - { collectBacktraces: false }, - ) - } catch (e) { - error = e - } - expect(error).to.be.an.instanceof(Error) - }) - - const span = exporter.getFinishedSpans()[0] - expect(span?.name).to.equal("child") - expect(span?.status).to.include({ - code: SpanStatusCode.ERROR, - message: "error", - }) - expect(span?.attributes).not.to.have.property( - SemanticAttributes.EXCEPTION_STACKTRACE, - ) - }) }) From d8d36479446497c32b22904713ba746ab8edf509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Mon, 20 Nov 2023 14:24:40 -0800 Subject: [PATCH 4/5] actually fix test --- packages/compat/package.json | 1 + packages/compat/test/index.test.ts | 15 ++++++++++++--- yarn.lock | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/compat/package.json b/packages/compat/package.json index 1a73ae82..52641f20 100644 --- a/packages/compat/package.json +++ b/packages/compat/package.json @@ -47,6 +47,7 @@ "@opentelemetry/api": "^1.3.0", "@opentelemetry/sdk-trace-base": "~1.18.1", "@opentelemetry/sdk-trace-node": "~1.18.1", + "@opentelemetry/semantic-conventions": "~1.18.1", "@solarwinds-apm/eslint-config": "workspace:^", "@solarwinds-apm/rollup-config": "workspace:^", "@solarwinds-apm/test": "workspace:^", diff --git a/packages/compat/test/index.test.ts b/packages/compat/test/index.test.ts index b99f21e8..157a8795 100644 --- a/packages/compat/test/index.test.ts +++ b/packages/compat/test/index.test.ts @@ -106,7 +106,10 @@ describe("instrument", () => { code: SpanStatusCode.ERROR, message: "error", }) - expect(span?.attributes).to.have.property( + expect(span?.events[0]!.attributes).to.include({ + [SemanticAttributes.EXCEPTION_MESSAGE]: "error", + }) + expect(span?.events[0]!.attributes).to.have.property( SemanticAttributes.EXCEPTION_STACKTRACE, ) }) @@ -151,7 +154,10 @@ describe("instrument", () => { code: SpanStatusCode.ERROR, message: "error", }) - expect(span?.attributes).to.have.property( + expect(span?.events[0]!.attributes).to.include({ + [SemanticAttributes.EXCEPTION_MESSAGE]: "error", + }) + expect(span?.events[0]!.attributes).to.have.property( SemanticAttributes.EXCEPTION_STACKTRACE, ) }) @@ -247,7 +253,10 @@ describe("pInstrument", () => { code: SpanStatusCode.ERROR, message: "error", }) - expect(span?.attributes).to.have.property( + expect(span?.events[0]!.attributes).to.include({ + [SemanticAttributes.EXCEPTION_MESSAGE]: "error", + }) + expect(span?.events[0]!.attributes).to.have.property( SemanticAttributes.EXCEPTION_STACKTRACE, ) }) diff --git a/yarn.lock b/yarn.lock index c4473e38..096daabf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1826,6 +1826,7 @@ __metadata: "@opentelemetry/api": "npm:^1.3.0" "@opentelemetry/sdk-trace-base": "npm:~1.18.1" "@opentelemetry/sdk-trace-node": "npm:~1.18.1" + "@opentelemetry/semantic-conventions": "npm:~1.18.1" "@solarwinds-apm/eslint-config": "workspace:^" "@solarwinds-apm/rollup-config": "workspace:^" "@solarwinds-apm/test": "workspace:^" From 89f8a3b853d3de4ce9078417ad1599157bb57f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Th=C3=A9riault?= Date: Mon, 20 Nov 2023 14:26:28 -0800 Subject: [PATCH 5/5] mark version bumps --- .yarn/versions/3e88a345.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .yarn/versions/3e88a345.yml diff --git a/.yarn/versions/3e88a345.yml b/.yarn/versions/3e88a345.yml new file mode 100644 index 00000000..474b7104 --- /dev/null +++ b/.yarn/versions/3e88a345.yml @@ -0,0 +1,2 @@ +releases: + "@solarwinds-apm/compat": minor