From 63a54f8bfc5a974dee05da79192e75c4f8e2d1d5 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Wed, 5 Mar 2025 12:32:51 -0500 Subject: [PATCH 01/38] initial scaffolding --- package-lock.json | 252 +++++++++++++++++- .../.eslintignore | 1 + .../.eslintrc.js | 9 + .../CHANGELOG.md | 2 + .../LICENSE | 201 ++++++++++++++ .../package.json | 77 ++++++ .../src/index.ts | 17 ++ .../src/instrumentation.ts | 29 ++ .../test/instrumentation.test.ts | 32 +++ .../tsconfig.esm.json | 11 + .../tsconfig.esnext.json | 11 + .../tsconfig.json | 11 + .../web-test-runner.config.mjs | 35 +++ 13 files changed, 687 insertions(+), 1 deletion(-) create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/.eslintignore create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/.eslintrc.js create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/CHANGELOG.md create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/LICENSE create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/package.json create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/src/index.ts create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esm.json create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.json create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs diff --git a/package-lock.json b/package-lock.json index 42e3d656bf..ab185ea6d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9320,6 +9320,10 @@ "resolved": "plugins/web/opentelemetry-instrumentation-user-interaction", "link": true }, + "node_modules/@opentelemetry/instrumentation-web-exception": { + "resolved": "plugins/web/opentelemetry-instrumentation-web-exception", + "link": true + }, "node_modules/@opentelemetry/instrumentation-winston": { "resolved": "plugins/node/opentelemetry-instrumentation-winston", "link": true @@ -37604,6 +37608,54 @@ "undici-types": "~5.26.4" } }, + "plugins/node/opentelemetry-instrumentation-winston/node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "plugins/web/opentelemetry-instrumentation-browser-exception": { + "version": "0.0.1", + "extraneous": true, + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "^1.8.0", + "@opentelemetry/instrumentation": "^0.57.2", + "@opentelemetry/sdk-trace-web": "^1.15.0", + "@opentelemetry/semantic-conventions": "^1.27.0" + }, + "devDependencies": { + "@babel/core": "7.22.17", + "@jsdevtools/coverage-istanbul-loader": "3.0.5", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/sdk-trace-base": "^1.0.0", + "@rollup/plugin-commonjs": "^26.0.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@types/chai": "^4.3.10", + "@types/mocha": "10.0.10", + "@types/node": "18.18.14", + "@types/sinon": "17.0.4", + "@web/dev-server-esbuild": "^1.0.1", + "@web/dev-server-rollup": "^0.6.1", + "@web/test-runner": "^0.18.0", + "chai": "^4.3.10", + "sinon": "15.2.0", + "typescript": "4.4.4" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, "plugins/web/opentelemetry-instrumentation-document-load": { "name": "@opentelemetry/instrumentation-document-load", "version": "0.45.0", @@ -37841,6 +37893,121 @@ "url": "https://opencollective.com/sinon" } }, + "plugins/web/opentelemetry-instrumentation-user-interaction/node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception": { + "name": "@opentelemetry/instrumentation-web-exception", + "version": "0.0.1", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "^1.8.0", + "@opentelemetry/instrumentation": "^0.57.2", + "@opentelemetry/sdk-trace-web": "^1.15.0", + "@opentelemetry/semantic-conventions": "^1.27.0" + }, + "devDependencies": { + "@babel/core": "7.22.17", + "@jsdevtools/coverage-istanbul-loader": "3.0.5", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/sdk-trace-base": "^1.0.0", + "@rollup/plugin-commonjs": "^26.0.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@types/chai": "^4.3.10", + "@types/mocha": "10.0.10", + "@types/node": "18.18.14", + "@types/sinon": "17.0.4", + "@web/dev-server-esbuild": "^1.0.1", + "@web/dev-server-rollup": "^0.6.1", + "@web/test-runner": "^0.18.0", + "chai": "^4.3.10", + "sinon": "15.2.0", + "typescript": "4.4.4" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@babel/core": { + "version": "7.22.17", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.17.tgz", + "integrity": "sha512-2EENLmhpwplDux5PSsZnSbnSkB3tZ6QTksgO25xwEL7pIDcNOMhF5v/s6RzwjMZzZzw9Ofc30gHv5ChCC8pifQ==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.22.15", + "@babel/helper-compilation-targets": "^7.22.15", + "@babel/helper-module-transforms": "^7.22.17", + "@babel/helpers": "^7.22.15", + "@babel/parser": "^7.22.16", + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.22.17", + "@babel/types": "^7.22.17", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@types/node": { + "version": "18.18.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", + "integrity": "sha512-iSOeNeXYNYNLLOMDSVPvIFojclvMZ/HDY2dU17kUlcsOsSQETbWIslJbYLZgA+ox8g2XQwSHKTkght1a5X26lQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "plugins/web/opentelemetry-plugin-react-load": { "name": "@opentelemetry/plugin-react-load", "version": "0.32.0", @@ -47236,6 +47403,89 @@ "nise": "^5.1.4", "supports-color": "^7.2.0" } + }, + "typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true + } + } + }, + "@opentelemetry/instrumentation-web-exception": { + "version": "file:plugins/web/opentelemetry-instrumentation-web-exception", + "requires": { + "@babel/core": "7.22.17", + "@jsdevtools/coverage-istanbul-loader": "3.0.5", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/core": "^1.8.0", + "@opentelemetry/instrumentation": "^0.57.2", + "@opentelemetry/sdk-trace-base": "^1.0.0", + "@opentelemetry/sdk-trace-web": "^1.15.0", + "@opentelemetry/semantic-conventions": "^1.27.0", + "@rollup/plugin-commonjs": "^26.0.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@types/chai": "^4.3.10", + "@types/mocha": "10.0.10", + "@types/node": "18.18.14", + "@types/sinon": "17.0.4", + "@web/dev-server-esbuild": "^1.0.1", + "@web/dev-server-rollup": "^0.6.1", + "@web/test-runner": "^0.18.0", + "chai": "^4.3.10", + "sinon": "15.2.0", + "typescript": "4.4.4" + }, + "dependencies": { + "@babel/core": { + "version": "7.22.17", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.17.tgz", + "integrity": "sha512-2EENLmhpwplDux5PSsZnSbnSkB3tZ6QTksgO25xwEL7pIDcNOMhF5v/s6RzwjMZzZzw9Ofc30gHv5ChCC8pifQ==", + "dev": true, + "requires": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.22.15", + "@babel/helper-compilation-targets": "^7.22.15", + "@babel/helper-module-transforms": "^7.22.17", + "@babel/helpers": "^7.22.15", + "@babel/parser": "^7.22.16", + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.22.17", + "@babel/types": "^7.22.17", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + } + }, + "@types/node": { + "version": "18.18.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", + "integrity": "sha512-iSOeNeXYNYNLLOMDSVPvIFojclvMZ/HDY2dU17kUlcsOsSQETbWIslJbYLZgA+ox8g2XQwSHKTkght1a5X26lQ==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, + "convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true + }, + "typescript": { + "version": "4.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", + "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", + "dev": true } } }, @@ -67546,4 +67796,4 @@ "integrity": "sha512-9oxn0IIjbCZkJ67L+LkhYWRyAy7axphb3VgE2MBDlOqnmHMPWGYMxJxBYFueFq/JGY2GMwS0rU+UCLunEmy5UA==" } } -} +} \ No newline at end of file diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/.eslintignore b/plugins/web/opentelemetry-instrumentation-web-exception/.eslintignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/.eslintignore @@ -0,0 +1 @@ +build diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/.eslintrc.js b/plugins/web/opentelemetry-instrumentation-web-exception/.eslintrc.js new file mode 100644 index 0000000000..6efcc3621d --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/.eslintrc.js @@ -0,0 +1,9 @@ +module.exports = { + env: { + mocha: true, + commonjs: true, + browser: true, + jquery: true, + }, + ...require('../../../eslint.config.js'), +}; diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/CHANGELOG.md b/plugins/web/opentelemetry-instrumentation-web-exception/CHANGELOG.md new file mode 100644 index 0000000000..4dc68c6ff8 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/CHANGELOG.md @@ -0,0 +1,2 @@ +# Changelog + diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/LICENSE b/plugins/web/opentelemetry-instrumentation-web-exception/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/package.json b/plugins/web/opentelemetry-instrumentation-web-exception/package.json new file mode 100644 index 0000000000..915675d5ca --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/package.json @@ -0,0 +1,77 @@ +{ + "name": "@opentelemetry/instrumentation-web-exception", + "version": "0.0.1", + "description": "OpenTelemetry instrumentation for web exceptions", + "main": "build/src/index.js", + "module": "build/esm/index.js", + "esnext": "build/esnext/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js-contrib", + "scripts": { + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "lint:readme": "node ../../../scripts/lint-readme.js", + "prewatch": "npm run precompile", + "version:update": "node ../../../scripts/version-update.js", + "compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json", + "prepublishOnly": "npm run compile", + "tdd": "wtr --watch", + "test:browser": "wtr --coverage", + "watch": "tsc --build -watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json" + }, + "keywords": [ + "opentelemetry", + "exception", + "web", + "tracing", + "plugin" + ], + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + }, + "files": [ + "build/esm/**/*.js", + "build/esm/**/*.map", + "build/esm/**/*.d.ts", + "build/esnext/**/*.js", + "build/esnext/**/*.map", + "build/esnext/**/*.d.ts", + "build/src/**/*.js", + "build/src/**/*.map", + "build/src/**/*.d.ts" + ], + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + }, + "devDependencies": { + "@babel/core": "7.22.17", + "@jsdevtools/coverage-istanbul-loader": "3.0.5", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/sdk-trace-base": "^1.0.0", + "@rollup/plugin-commonjs": "^26.0.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@types/chai": "^4.3.10", + "@types/mocha": "10.0.10", + "@types/node": "18.18.14", + "@types/sinon": "17.0.4", + "@web/dev-server-esbuild": "^1.0.1", + "@web/dev-server-rollup": "^0.6.1", + "@web/test-runner": "^0.18.0", + "chai": "^4.3.10", + "sinon": "15.2.0", + "typescript": "4.4.4" + }, + "dependencies": { + "@opentelemetry/core": "^1.8.0", + "@opentelemetry/instrumentation": "^0.57.2", + "@opentelemetry/sdk-trace-web": "^1.15.0", + "@opentelemetry/semantic-conventions": "^1.27.0" + }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load#readme" +} \ No newline at end of file diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/index.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/index.ts new file mode 100644 index 0000000000..24c76056a1 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './instrumentation'; diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts new file mode 100644 index 0000000000..13576115bc --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -0,0 +1,29 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + InstrumentationBase, + InstrumentationConfig, +} from '@opentelemetry/instrumentation'; + +export class WebExceptionInstrumentation extends InstrumentationBase { + constructor(config: InstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-web-exception', '0.0.1', config); + console.log('WebExceptionInstrumentation was constructed'); + } + + init() {} +} diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts new file mode 100644 index 0000000000..4d706a5f9d --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts @@ -0,0 +1,32 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { WebExceptionInstrumentation } from '../src/instrumentation'; +// @ts-expect-error: not an export, but we want the prebundled version +import chai from 'chai/chai.js'; + +const assert = chai.assert; + +describe('WebExceptionInstrumentation', () => { + describe('constructor', () => { + it('should construct an instance', () => { + const instrumentation = new WebExceptionInstrumentation({ + enabled: false, + }); + assert.ok(instrumentation instanceof WebExceptionInstrumentation); + }); + }); +}); diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esm.json b/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esm.json new file mode 100644 index 0000000000..379f547a46 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json b/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json new file mode 100644 index 0000000000..cb78dd6ff3 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.base.esnext.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esnext", + "tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.json b/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.json new file mode 100644 index 0000000000..28be80d266 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +} diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs b/plugins/web/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs new file mode 100644 index 0000000000..1989a756fd --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs @@ -0,0 +1,35 @@ +/*! + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { nodeResolve as nodeResolveRollup } from '@rollup/plugin-node-resolve'; +import commonjsRollup from '@rollup/plugin-commonjs'; +import { esbuildPlugin } from '@web/dev-server-esbuild'; +import { fromRollup } from '@web/dev-server-rollup'; +import { chromeLauncher } from '@web/test-runner'; + +const nodeResolve = fromRollup(nodeResolveRollup); +const commonjs = fromRollup(commonjsRollup); + +export default { + files: ['test/**/*.test.ts'], + nodeResolve: true, + browsers: [chromeLauncher({ launchOptions: { args: ['--no-sandbox'] } })], + plugins: [ + esbuildPlugin({ ts: true }), + nodeResolve({ browser: true, preferBuiltins: false }), + commonjs(), + ], +}; From 4a86d7f301e9b3dd208605614612828dc89b959c Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Fri, 7 Mar 2025 10:44:40 -0500 Subject: [PATCH 02/38] very basic implementation of errors autoinstrumentation --- package-lock.json | 23 ++++++++ .../package.json | 3 +- .../src/instrumentation.ts | 58 ++++++++++++++++++- 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab185ea6d6..a6b60aab68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8791,6 +8791,18 @@ "node": ">=8.0.0" } }, + "node_modules/@opentelemetry/api-events": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-events/-/api-events-0.57.2.tgz", + "integrity": "sha512-jZn3FKfA3wyBznfJA+yCa3IZFTwT1HtVjPg3ueFEAInz33CsUbfX1otJR97nyhL8SnUgwo73lcGAg9+xv5ZBxg==", + "dependencies": { + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/api-logs": "0.57.2" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/@opentelemetry/api-logs": { "version": "0.200.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.200.0.tgz", @@ -37911,6 +37923,7 @@ "version": "0.0.1", "license": "Apache-2.0", "dependencies": { + "@opentelemetry/api-events": "^0.57.2", "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/sdk-trace-web": "^1.15.0", @@ -44831,6 +44844,15 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==" }, + "@opentelemetry/api-events": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-events/-/api-events-0.57.2.tgz", + "integrity": "sha512-jZn3FKfA3wyBznfJA+yCa3IZFTwT1HtVjPg3ueFEAInz33CsUbfX1otJR97nyhL8SnUgwo73lcGAg9+xv5ZBxg==", + "requires": { + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/api-logs": "0.57.2" + } + }, "@opentelemetry/api-logs": { "version": "0.200.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.200.0.tgz", @@ -47418,6 +47440,7 @@ "@babel/core": "7.22.17", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", + "@opentelemetry/api-events": "^0.57.2", "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/package.json b/plugins/web/opentelemetry-instrumentation-web-exception/package.json index 915675d5ca..4049fb1ed9 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/package.json +++ b/plugins/web/opentelemetry-instrumentation-web-exception/package.json @@ -68,10 +68,11 @@ "typescript": "4.4.4" }, "dependencies": { + "@opentelemetry/api-events": "^0.57.2", "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/sdk-trace-web": "^1.15.0", "@opentelemetry/semantic-conventions": "^1.27.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load#readme" -} \ No newline at end of file +} diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index 13576115bc..e4c72084f6 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -18,12 +18,68 @@ import { InstrumentationBase, InstrumentationConfig, } from '@opentelemetry/instrumentation'; +import { + ATTR_EXCEPTION_TYPE, + ATTR_EXCEPTION_MESSAGE, + ATTR_EXCEPTION_STACKTRACE, +} from '@opentelemetry/semantic-conventions'; +// TODO: should events be imported or included as part of the instrumentation base class? +import { events } from '@opentelemetry/api-events'; +import { SeverityNumber } from '@opentelemetry/api-logs'; +import { Attributes } from '@opentelemetry/api'; + +export interface GlobalErrorsInstrumentationConfig + extends InstrumentationConfig { + /** + * A callback function for adding custom attributes to the span when an error is recorded. + * + * @param {Error} error - The error object that is being recorded. + * @returns {Attributes} - The attributes to add to the span. + */ + applyCustomAttributes?: (error: Error) => Attributes; +} export class WebExceptionInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { super('@opentelemetry/instrumentation-web-exception', '0.0.1', config); - console.log('WebExceptionInstrumentation was constructed'); } init() {} + + onError = (event: ErrorEvent | PromiseRejectionEvent) => { + const error: Error | undefined = + 'reason' in event ? event.reason : event.error; + if (error) { + const message = error.message; + const type = error.name; + const errorAttributes = { + [ATTR_EXCEPTION_TYPE]: type, + [ATTR_EXCEPTION_MESSAGE]: message, + [ATTR_EXCEPTION_STACKTRACE]: error.stack, + }; + + const eventLogger = events.getEventLogger( + this.instrumentationName, + this.instrumentationVersion + ); + + eventLogger.emit({ + name: 'exception', + data: errorAttributes, + // TODO: add attributes from apply custom attributes function + severityNumber: SeverityNumber.ERROR, + // TODO: figure out timestamp + }); + } + }; + + override disable(): void { + window.removeEventListener('error', this.onError); + window.removeEventListener('unhandledrejection', this.onError); + } + + override enable(): void { + window.addEventListener('error', this.onError); + window.addEventListener('unhandledrejection', this.onError); + } } From 9af0aedf979cebbbfbf73a526020ac51e9b9fe93 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 10:37:31 -0400 Subject: [PATCH 03/38] add test --- package-lock.json | 32 +++++++++++ .../package.json | 2 + .../test/instrumentation.test.ts | 56 ++++++++++++++++++- 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a6b60aab68..4701d3933f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9513,6 +9513,23 @@ "@opentelemetry/api": ">=1.3.0 <1.10.0" } }, + "node_modules/@opentelemetry/sdk-events": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-events/-/sdk-events-0.57.2.tgz", + "integrity": "sha512-fSgRfZzf3H8adjt8Xk8C145gDD/Hw5KtLaXVzDO8nLQaYiC3mvLIUtrPjbEqzHHPDUSBsVqiDszQ27Iaa+QZKg==", + "dev": true, + "dependencies": { + "@opentelemetry/api-events": "0.57.2", + "@opentelemetry/api-logs": "0.57.2", + "@opentelemetry/sdk-logs": "0.57.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.10.0" + } + }, "node_modules/@opentelemetry/sdk-logs": { "version": "0.200.0", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.200.0.tgz", @@ -37933,6 +37950,8 @@ "@babel/core": "7.22.17", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", + "@opentelemetry/sdk-events": "^0.57.2", + "@opentelemetry/sdk-logs": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", "@rollup/plugin-commonjs": "^26.0.0", "@rollup/plugin-node-resolve": "^15.2.3", @@ -47443,6 +47462,8 @@ "@opentelemetry/api-events": "^0.57.2", "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.57.2", + "@opentelemetry/sdk-events": "^0.57.2", + "@opentelemetry/sdk-logs": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", "@opentelemetry/sdk-trace-web": "^1.15.0", "@opentelemetry/semantic-conventions": "^1.27.0", @@ -48169,6 +48190,17 @@ "@opentelemetry/semantic-conventions": "^1.29.0" } }, + "@opentelemetry/sdk-events": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-events/-/sdk-events-0.57.2.tgz", + "integrity": "sha512-fSgRfZzf3H8adjt8Xk8C145gDD/Hw5KtLaXVzDO8nLQaYiC3mvLIUtrPjbEqzHHPDUSBsVqiDszQ27Iaa+QZKg==", + "dev": true, + "requires": { + "@opentelemetry/api-events": "0.57.2", + "@opentelemetry/api-logs": "0.57.2", + "@opentelemetry/sdk-logs": "0.57.2" + } + }, "@opentelemetry/sdk-logs": { "version": "0.200.0", "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.200.0.tgz", diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/package.json b/plugins/web/opentelemetry-instrumentation-web-exception/package.json index 4049fb1ed9..ead4b44c94 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/package.json +++ b/plugins/web/opentelemetry-instrumentation-web-exception/package.json @@ -53,6 +53,8 @@ "@babel/core": "7.22.17", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", + "@opentelemetry/sdk-events": "^0.57.2", + "@opentelemetry/sdk-logs": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", "@rollup/plugin-commonjs": "^26.0.0", "@rollup/plugin-node-resolve": "^15.2.3", diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts index 4d706a5f9d..c4655afe26 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts @@ -17,10 +17,25 @@ import { WebExceptionInstrumentation } from '../src/instrumentation'; // @ts-expect-error: not an export, but we want the prebundled version import chai from 'chai/chai.js'; - +import { EventLoggerProvider } from '@opentelemetry/sdk-events'; +import { + LoggerProvider, + SimpleLogRecordProcessor, + InMemoryLogRecordExporter, +} from '@opentelemetry/sdk-logs'; +import { events } from '@opentelemetry/api-events'; +import { registerInstrumentations } from '@opentelemetry/instrumentation'; const assert = chai.assert; describe('WebExceptionInstrumentation', () => { + const loggerProvider = new LoggerProvider(); + const exporter = new InMemoryLogRecordExporter(); + const logRecordProcessor = new SimpleLogRecordProcessor(exporter); + loggerProvider.addLogRecordProcessor(logRecordProcessor); + + const eventLoggerProvider = new EventLoggerProvider(loggerProvider); + events.setGlobalEventLoggerProvider(eventLoggerProvider); + describe('constructor', () => { it('should construct an instance', () => { const instrumentation = new WebExceptionInstrumentation({ @@ -29,4 +44,43 @@ describe('WebExceptionInstrumentation', () => { assert.ok(instrumentation instanceof WebExceptionInstrumentation); }); }); + + describe('throwing an error', () => { + beforeEach(() => { + const instr = new WebExceptionInstrumentation(); + registerInstrumentations({ + instrumentations: [instr], + }); + instr.enable(); + }); + + it('should create an event when an error is thrown', async () => { + const err = new Error('Something happened!'); + err.stack = + '' + + ' Error: Something happened\n' + + ' at baz (filename.js:10:15)\n' + + ' at bar (filename.js:6:3)\n' + + ' at foo (filename.js:2:3)\n' + + ' at (filename.js:13:1)'; + setTimeout(() => { + try { + throw err; + } catch (error) { + assert.ok(error instanceof Error); + // Do nothing + } + }); + + // Wait for error to be processed and log to be created + setTimeout(() => { + try { + const events = exporter.getFinishedLogRecords(); + assert.ok(events.length > 0, 'Expected at least one log record'); + const event = events[0]; + assert.ok(event.attributes['event.name'] === 'exception'); + } catch (e) {} + }, 0); + }); + }); }); From ad1d248ec05c13d4662ff3e16235e3b76532af55 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 14:09:07 -0400 Subject: [PATCH 04/38] fix tests --- .../test/instrumentation.test.ts | 83 +++++++++++++++---- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts index c4655afe26..b2f9a5b89b 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts @@ -25,6 +25,11 @@ import { } from '@opentelemetry/sdk-logs'; import { events } from '@opentelemetry/api-events'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; +import { + ATTR_EXCEPTION_MESSAGE, + ATTR_EXCEPTION_STACKTRACE, + ATTR_EXCEPTION_TYPE, +} from '@opentelemetry/semantic-conventions'; const assert = chai.assert; describe('WebExceptionInstrumentation', () => { @@ -36,6 +41,21 @@ describe('WebExceptionInstrumentation', () => { const eventLoggerProvider = new EventLoggerProvider(loggerProvider); events.setGlobalEventLoggerProvider(eventLoggerProvider); + // Helper function to throw an error of a specific type so that we can allow the error to propagate and test the instrumentation. + const throwErr = (message: string, stack?: string): void => { + class ValidationError extends Error { + constructor(message: string) { + super(message); + this.name = 'ValidationError'; + } + } + const err = new ValidationError(message); + if (stack) { + err.stack = stack; + } + throw err; + }; + describe('constructor', () => { it('should construct an instance', () => { const instrumentation = new WebExceptionInstrumentation({ @@ -46,17 +66,53 @@ describe('WebExceptionInstrumentation', () => { }); describe('throwing an error', () => { + let mochaErrorHandler: OnErrorEventHandler; + const instr = new WebExceptionInstrumentation(); beforeEach(() => { - const instr = new WebExceptionInstrumentation(); + mochaErrorHandler = window.onerror; + // We need to handle the error ourselves to prevent Mocha from failing the test. + window.onerror = ( + event: Event | string, + source?: string, + lineno?: number, + colno?: number, + error?: Error + ) => { + if (error?.name !== 'ValidationError') { + // If we are testing our instrumentation, we want to let the error propagate. + // If it is any other kind of error, we want Mocha to handle the error as expected. + mochaErrorHandler?.call(window, event, source, lineno, colno, error); + } + }; registerInstrumentations({ instrumentations: [instr], }); + instr.enable(); }); + afterEach(() => { + // Resume Mocha handling of uncaughtExceptions. + window.onerror = mochaErrorHandler; + instr.disable(); + exporter.reset(); + }); + it('should create an event when an error is thrown', async () => { - const err = new Error('Something happened!'); - err.stack = + setTimeout(() => { + throwErr('Something happened!'); + }); + + setTimeout(() => { + const events = exporter.getFinishedLogRecords(); + assert.ok(events.length > 0, 'Expected at least one log record'); + const event = events[0]; + assert.strictEqual(event.attributes['event.name'], 'exception'); + }, 0); + }); + + it('should apply semantic attributes for exceptions to the event', async () => { + const stack = '' + ' Error: Something happened\n' + ' at baz (filename.js:10:15)\n' + @@ -64,22 +120,17 @@ describe('WebExceptionInstrumentation', () => { ' at foo (filename.js:2:3)\n' + ' at (filename.js:13:1)'; setTimeout(() => { - try { - throw err; - } catch (error) { - assert.ok(error instanceof Error); - // Do nothing - } + throwErr('Something happened!', stack); }); - // Wait for error to be processed and log to be created setTimeout(() => { - try { - const events = exporter.getFinishedLogRecords(); - assert.ok(events.length > 0, 'Expected at least one log record'); - const event = events[0]; - assert.ok(event.attributes['event.name'] === 'exception'); - } catch (e) {} + const events = exporter.getFinishedLogRecords(); + assert.ok(events.length > 0, 'Expected at least one log record'); + const event = events[0]; + const body = event.body as Record; + assert.strictEqual(body[ATTR_EXCEPTION_MESSAGE], 'Something happened!'); + assert.strictEqual(body[ATTR_EXCEPTION_TYPE], 'ValidationError'); + assert.strictEqual(body[ATTR_EXCEPTION_STACKTRACE], stack); }, 0); }); }); From 87909a29a25991acafca85c9fd8551358c7b779d Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 14:25:41 -0400 Subject: [PATCH 05/38] apply custom attributes function --- .../src/instrumentation.ts | 16 ++-- .../test/instrumentation.test.ts | 80 ++++++++++++++----- 2 files changed, 73 insertions(+), 23 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index e4c72084f6..b617bc28ca 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -39,9 +39,12 @@ export interface GlobalErrorsInstrumentationConfig applyCustomAttributes?: (error: Error) => Attributes; } -export class WebExceptionInstrumentation extends InstrumentationBase { - constructor(config: InstrumentationConfig = {}) { +export class WebExceptionInstrumentation extends InstrumentationBase { + readonly applyCustomAttributes?: (error: Error) => Attributes; + constructor(config: GlobalErrorsInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-web-exception', '0.0.1', config); + + this.applyCustomAttributes = config.applyCustomAttributes; } init() {} @@ -63,12 +66,15 @@ export class WebExceptionInstrumentation extends InstrumentationBase { throw err; }; + let mochaErrorHandler: OnErrorEventHandler; + + beforeEach(() => { + mochaErrorHandler = window.onerror; + // We need to handle the error ourselves to prevent Mocha from failing the test. + window.onerror = ( + event: Event | string, + source?: string, + lineno?: number, + colno?: number, + error?: Error + ) => { + if (error?.name !== 'ValidationError') { + // If we are testing our instrumentation, we want to let the error propagate. + // If it is any other kind of error, we want Mocha to handle the error as expected. + mochaErrorHandler?.call(window, event, source, lineno, colno, error); + } + }; + }); + + afterEach(() => { + // Resume Mocha handling of uncaughtExceptions. + window.onerror = mochaErrorHandler; + }); + describe('constructor', () => { it('should construct an instance', () => { const instrumentation = new WebExceptionInstrumentation({ @@ -66,24 +91,8 @@ describe('WebExceptionInstrumentation', () => { }); describe('throwing an error', () => { - let mochaErrorHandler: OnErrorEventHandler; const instr = new WebExceptionInstrumentation(); beforeEach(() => { - mochaErrorHandler = window.onerror; - // We need to handle the error ourselves to prevent Mocha from failing the test. - window.onerror = ( - event: Event | string, - source?: string, - lineno?: number, - colno?: number, - error?: Error - ) => { - if (error?.name !== 'ValidationError') { - // If we are testing our instrumentation, we want to let the error propagate. - // If it is any other kind of error, we want Mocha to handle the error as expected. - mochaErrorHandler?.call(window, event, source, lineno, colno, error); - } - }; registerInstrumentations({ instrumentations: [instr], }); @@ -92,8 +101,6 @@ describe('WebExceptionInstrumentation', () => { }); afterEach(() => { - // Resume Mocha handling of uncaughtExceptions. - window.onerror = mochaErrorHandler; instr.disable(); exporter.reset(); }); @@ -134,4 +141,41 @@ describe('WebExceptionInstrumentation', () => { }, 0); }); }); + + describe('adding custom attributes', () => { + const applyCustomAttrs = (error: Error) => { + return { + 'app.custom.exception': error.message.toLocaleUpperCase(), + }; + }; + const instr = new WebExceptionInstrumentation({ + applyCustomAttributes: applyCustomAttrs, + }); + beforeEach(() => { + registerInstrumentations({ + instrumentations: [instr], + }); + + instr.enable(); + }); + + afterEach(() => { + instr.disable(); + exporter.reset(); + }); + it('should add custom attributes to the event', async () => { + setTimeout(() => { + throwErr('Something happened!'); + }); + + setTimeout(() => { + const events = exporter.getFinishedLogRecords(); + assert.ok(events.length > 0, 'Expected at least one log record'); + const event = events[0]; + const body = event.body as Record; + console.log(event); + assert.strictEqual(body['app.custom.exception'], 'SOMETHING HAPPENED!'); + }, 0); + }); + }); }); From 77f9bc79f20cdce768703389373336fd5f234094 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 14:30:06 -0400 Subject: [PATCH 06/38] remove console.log --- .../test/instrumentation.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts index b4ff4513b2..2f371b8a99 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts @@ -173,7 +173,6 @@ describe('WebExceptionInstrumentation', () => { assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; const body = event.body as Record; - console.log(event); assert.strictEqual(body['app.custom.exception'], 'SOMETHING HAPPENED!'); }, 0); }); From 0bffbac3189f75bd4e1aa19380c7b98dc715c085 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 15:25:15 -0400 Subject: [PATCH 07/38] add readme --- .../README.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 plugins/web/opentelemetry-instrumentation-web-exception/README.md diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/README.md b/plugins/web/opentelemetry-instrumentation-web-exception/README.md new file mode 100644 index 0000000000..5024608a3d --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-web-exception/README.md @@ -0,0 +1,98 @@ +# OpenTelemetry Web Exception Instrumentation + +[![NPM Published Version][npm-img]][npm-url] +[![Apache License][license-image]][license-image-url] + +This module provides automatic instrumentation for capturing unhandled exceptions and promise rejections in web applications. + +## Installation + +```bash +npm install --save @opentelemetry/instrumentation-web-exception +``` + +## Usage + +```typescript +import { LoggerProvider } from '@opentelemetry/sdk-logs'; +import { EventLoggerProvider, events } from '@opentelemetry/api-events'; +import { WebExceptionInstrumentation } from '@opentelemetry/instrumentation-web-exception'; +import { registerInstrumentations } from '@opentelemetry/instrumentation'; + +// Set up the logger provider and event logger +const loggerProvider = new LoggerProvider(); +const eventLoggerProvider = new EventLoggerProvider(loggerProvider); +events.setGlobalEventLoggerProvider(eventLoggerProvider); + +// Register the instrumentation +registerInstrumentations({ + instrumentations: [ + new WebExceptionInstrumentation({ + // Optional: customize attributes added to error events + applyCustomAttributes: (error) => ({ + 'app.error.severity': error.name === 'ValidationError' ? 'warning' : 'error', + 'custom.correlation.id': window.correlationId, + }), + }), + ], +}); +``` + +## Configuration + +The instrumentation can be configured with the following options: + +| Option | Type | Description | +| ------- | ---- | ----------- | +| `enabled` | `boolean` | Whether to enable the instrumentation. Default: `true` | +| `applyCustomAttributes` | `(error: Error) => Attributes` | Optional callback to add custom attributes to error events | + +## Features + +- Automatically captures unhandled exceptions +- Captures unhandled promise rejections +- Records error name, message, and stack trace using OpenTelemetry semantic conventions +- Supports custom attributes through configuration +- Integrates with OpenTelemetry Events API + +## Semantic Attributes + +The following semantic attributes are added to each error event: + +| Attribute | Type | Description | +| --------- | ---- | ----------- | +| `exception.type` | string | The error name or type | +| `exception.message` | string | The error message | +| `exception.stacktrace` | string | The error stack trace | + +## Example + +```typescript +// Initialize the instrumentation +const exceptionInstrumentation = new WebExceptionInstrumentation({ + applyCustomAttributes: (error) => ({ + 'error.category': error instanceof TypeError ? 'type_error' : 'runtime_error', + 'app.version': '1.0.0', + }), +}); + +// The instrumentation will automatically capture unhandled errors +throw new Error('Unhandled error'); + +// And unhandled promise rejections +Promise.reject(new Error('Unhandled rejection')); +``` + +## Contributing + +This instrumentation is maintained by the OpenTelemetry authors. We welcome contributions! + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-web-exception +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-web-exception.svg +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg +[license-image-url]: https://img.shields.io/badge/license-Apache_2.0-green.svg From 21881cd6f66ad9dc2c2ee56f95b9216ac756a784 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 15:28:43 -0400 Subject: [PATCH 08/38] update dependencies --- package-lock.json | 6 ++---- .../package.json | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4701d3933f..dbecc3a5f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37941,15 +37941,14 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-events": "^0.57.2", - "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.57.2", - "@opentelemetry/sdk-trace-web": "^1.15.0", "@opentelemetry/semantic-conventions": "^1.27.0" }, "devDependencies": { "@babel/core": "7.22.17", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", + "@opentelemetry/api-logs": "^0.57.2", "@opentelemetry/sdk-events": "^0.57.2", "@opentelemetry/sdk-logs": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", @@ -47460,12 +47459,11 @@ "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", "@opentelemetry/api-events": "^0.57.2", - "@opentelemetry/core": "^1.8.0", + "@opentelemetry/api-logs": "^0.57.2", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/sdk-events": "^0.57.2", "@opentelemetry/sdk-logs": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", - "@opentelemetry/sdk-trace-web": "^1.15.0", "@opentelemetry/semantic-conventions": "^1.27.0", "@rollup/plugin-commonjs": "^26.0.0", "@rollup/plugin-node-resolve": "^15.2.3", diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/package.json b/plugins/web/opentelemetry-instrumentation-web-exception/package.json index ead4b44c94..f83f9fe281 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/package.json +++ b/plugins/web/opentelemetry-instrumentation-web-exception/package.json @@ -53,6 +53,7 @@ "@babel/core": "7.22.17", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", + "@opentelemetry/api-logs": "^0.57.2", "@opentelemetry/sdk-events": "^0.57.2", "@opentelemetry/sdk-logs": "^0.57.2", "@opentelemetry/sdk-trace-base": "^1.0.0", @@ -71,9 +72,7 @@ }, "dependencies": { "@opentelemetry/api-events": "^0.57.2", - "@opentelemetry/core": "^1.8.0", "@opentelemetry/instrumentation": "^0.57.2", - "@opentelemetry/sdk-trace-web": "^1.15.0", "@opentelemetry/semantic-conventions": "^1.27.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load#readme" From 68eb7f920f8af8689c658f93a4eb7ecca764b507 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 15:30:26 -0400 Subject: [PATCH 09/38] add to release please --- .release-please-manifest.json | 2 +- release-please-config.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 16d91bc486..b2c4704a6f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -64,4 +64,4 @@ "propagators/opentelemetry-propagator-ot-trace": "0.28.0", "propagators/propagator-aws-xray": "2.0.0", "propagators/propagator-aws-xray-lambda": "0.54.0" -} +} \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json index a55d06f9ec..a2f94a2378 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -66,10 +66,11 @@ "plugins/web/opentelemetry-instrumentation-document-load": {}, "plugins/web/opentelemetry-instrumentation-long-task": {}, "plugins/web/opentelemetry-instrumentation-user-interaction": {}, + "plugins/web/opentelemetry-instrumentation-web-exception": {}, "plugins/web/opentelemetry-plugin-react-load": {}, "propagators/opentelemetry-propagator-instana": {}, "propagators/opentelemetry-propagator-ot-trace": {}, "propagators/propagator-aws-xray": {}, "propagators/propagator-aws-xray-lambda": {} } -} +} \ No newline at end of file From 2610155d206a174f4a22dfefa58ba577e7298e3c Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Mon, 10 Mar 2025 15:38:43 -0400 Subject: [PATCH 10/38] fix lint for readme --- .../README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/README.md b/plugins/web/opentelemetry-instrumentation-web-exception/README.md index 5024608a3d..1e0faf2aab 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/README.md +++ b/plugins/web/opentelemetry-instrumentation-web-exception/README.md @@ -1,7 +1,7 @@ # OpenTelemetry Web Exception Instrumentation [![NPM Published Version][npm-img]][npm-url] -[![Apache License][license-image]][license-image-url] +[![Apache License][license-image]][license-image] This module provides automatic instrumentation for capturing unhandled exceptions and promise rejections in web applications. @@ -83,16 +83,18 @@ throw new Error('Unhandled error'); Promise.reject(new Error('Unhandled rejection')); ``` -## Contributing +## Useful links -This instrumentation is maintained by the OpenTelemetry authors. We welcome contributions! +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License Apache 2.0 - See [LICENSE][license-url] for more information. +[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-web-exception [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-web-exception.svg -[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE -[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg -[license-image-url]: https://img.shields.io/badge/license-Apache_2.0-green.svg From 55f6be61a2120abd4f9fa0ad8cfbf296a5b1c081 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Wed, 12 Mar 2025 13:14:01 -0400 Subject: [PATCH 11/38] use htTime instead --- .../src/instrumentation.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index b617bc28ca..989750a4e2 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -27,6 +27,7 @@ import { import { events } from '@opentelemetry/api-events'; import { SeverityNumber } from '@opentelemetry/api-logs'; import { Attributes } from '@opentelemetry/api'; +import { hrTime } from '@opentelemetry/core'; export interface GlobalErrorsInstrumentationConfig extends InstrumentationConfig { @@ -74,7 +75,7 @@ export class WebExceptionInstrumentation extends InstrumentationBase Date: Wed, 12 Mar 2025 13:15:52 -0400 Subject: [PATCH 12/38] match semconv for name --- .../src/instrumentation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index 989750a4e2..655280f924 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -72,7 +72,7 @@ export class WebExceptionInstrumentation extends InstrumentationBase Date: Wed, 12 Mar 2025 13:27:12 -0400 Subject: [PATCH 13/38] use attributes for user provided attrs --- .../src/instrumentation.ts | 3 ++- .../test/instrumentation.test.ts | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index 655280f924..d352583e39 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -73,7 +73,8 @@ export class WebExceptionInstrumentation extends InstrumentationBase { const events = exporter.getFinishedLogRecords(); assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - const body = event.body as Record; - assert.strictEqual(body['app.custom.exception'], 'SOMETHING HAPPENED!'); + assert.strictEqual( + event.attributes['app.custom.exception'], + 'SOMETHING HAPPENED!' + ); }, 0); }); }); From ed14b8ee7030d014e8f174aa897b0b0a58594727 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Tue, 22 Apr 2025 11:09:24 -0400 Subject: [PATCH 14/38] switch to "exception" for name --- .../src/instrumentation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index d352583e39..c07f5b9783 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -72,7 +72,7 @@ export class WebExceptionInstrumentation extends InstrumentationBase Date: Tue, 22 Apr 2025 11:31:50 -0400 Subject: [PATCH 15/38] add core as a dependency --- package-lock.json | 310 ++++++++++++------ .../package.json | 9 +- 2 files changed, 217 insertions(+), 102 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbecc3a5f9..a3d4bbf82c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35839,31 +35839,6 @@ "@opentelemetry/api": "^1.3.0" } }, - "plugins/node/opentelemetry-instrumentation-aws-sdk/node_modules/@aws-sdk/types": { - "version": "3.370.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.370.0.tgz", - "integrity": "sha512-8PGMKklSkRKjunFhzM2y5Jm0H2TBu7YRNISdYzXLUHKSP9zlMEYagseKVdmox0zKHf1LXVNuSlUV2b6SRrieCQ==", - "dev": true, - "dependencies": { - "@smithy/types": "^1.1.0", - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "plugins/node/opentelemetry-instrumentation-aws-sdk/node_modules/@smithy/types": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-1.2.0.tgz", - "integrity": "sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==", - "dev": true, - "dependencies": { - "tslib": "^2.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, "plugins/node/opentelemetry-instrumentation-aws-sdk/node_modules/@types/node": { "version": "18.18.14", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", @@ -37637,19 +37612,6 @@ "undici-types": "~5.26.4" } }, - "plugins/node/opentelemetry-instrumentation-winston/node_modules/typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "plugins/web/opentelemetry-instrumentation-browser-exception": { "version": "0.0.1", "extraneous": true, @@ -37922,25 +37884,13 @@ "url": "https://opencollective.com/sinon" } }, - "plugins/web/opentelemetry-instrumentation-user-interaction/node_modules/typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "plugins/web/opentelemetry-instrumentation-web-exception": { "name": "@opentelemetry/instrumentation-web-exception", "version": "0.0.1", "license": "Apache-2.0", "dependencies": { "@opentelemetry/api-events": "^0.57.2", + "@opentelemetry/core": "^1.30.1", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/semantic-conventions": "^1.27.0" }, @@ -37963,10 +37913,10 @@ "@web/test-runner": "^0.18.0", "chai": "^4.3.10", "sinon": "15.2.0", - "typescript": "4.4.4" + "typescript": "^5.0.4" }, "engines": { - "node": ">=14" + "node": "^18.19.0 || >=20.6.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" @@ -38002,6 +37952,127 @@ "url": "https://opencollective.com/babel" } }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/api-logs": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.57.2.tgz", + "integrity": "sha512-uIX52NnTM0iBh84MShlpouI7UKqkZ7MrUszTmaypHBu4r7NofznSnQRfJ+uUeDtQDj6w8eFGg5KBLDAwAPz1+A==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api": "^1.3.0" + }, + "engines": { + "node": ">=14" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/core": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.30.1.tgz", + "integrity": "sha512-OOCM2C/QIURhJMuKaekP3TRBxBKxG/TWWA0TL2J6nXUtDnuCtccy49LUJF8xPFXMX+0LMcxFpCo8M9cGY1W6rQ==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.28.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/instrumentation": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.57.2.tgz", + "integrity": "sha512-BdBGhQBh8IjZ2oIIX6F2/Q3LKm/FDDKi6ccYKcBTeilh6SNdNKveDOLk73BkSJjQLJk6qe4Yh+hHw1UPhCDdrg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "0.57.2", + "@types/shimmer": "^1.2.0", + "import-in-the-middle": "^1.8.1", + "require-in-the-middle": "^7.1.1", + "semver": "^7.5.2", + "shimmer": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/instrumentation/node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/resources": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.30.1.tgz", + "integrity": "sha512-5UxZqiAgLYGFjS4s9qm5mBVo433u+dSPUFWVWXmLAD4wB65oMCoXaJP1KJa9DIYYMeHu3z4BZcStG3LC593cWA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "1.30.1", + "@opentelemetry/semantic-conventions": "1.28.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/sdk-logs": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.57.2.tgz", + "integrity": "sha512-TXFHJ5c+BKggWbdEQ/inpgIzEmS2BGQowLE9UhsMd7YYlUfBQJ4uax0VF/B5NYigdM/75OoJGhAV3upEhK+3gg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "0.57.2", + "@opentelemetry/core": "1.30.1", + "@opentelemetry/resources": "1.30.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.10.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.30.1.tgz", + "integrity": "sha512-jVPgBbH1gCy2Lb7X0AVQ8XAfgg0pJ4nvl8/IiQA6nxOsPvS+0zMJaFSs2ltXe0J6C8dqjcnpyqINDJmU30+uOg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "1.30.1", + "@opentelemetry/resources": "1.30.1", + "@opentelemetry/semantic-conventions": "1.28.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.28.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.28.0.tgz", + "integrity": "sha512-lp4qAiMTD4sNWW4DbKLBkfiMZ4jbAboJIGOQr5DvciMRI494OapieI9qiODpOt0XBr1LjIDy1xAGAnVs5supTA==", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + } + }, "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@types/node": { "version": "18.18.14", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", @@ -38011,6 +38082,12 @@ "undici-types": "~5.26.4" } }, + "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/@types/shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==", + "license": "MIT" + }, "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", @@ -38026,19 +38103,6 @@ "semver": "bin/semver.js" } }, - "plugins/web/opentelemetry-instrumentation-web-exception/node_modules/typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "plugins/web/opentelemetry-plugin-react-load": { "name": "@opentelemetry/plugin-react-load", "version": "0.32.0", @@ -45483,25 +45547,6 @@ "typescript": "5.0.4" }, "dependencies": { - "@aws-sdk/types": { - "version": "3.370.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.370.0.tgz", - "integrity": "sha512-8PGMKklSkRKjunFhzM2y5Jm0H2TBu7YRNISdYzXLUHKSP9zlMEYagseKVdmox0zKHf1LXVNuSlUV2b6SRrieCQ==", - "dev": true, - "requires": { - "@smithy/types": "^1.1.0", - "tslib": "^2.5.0" - } - }, - "@smithy/types": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-1.2.0.tgz", - "integrity": "sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==", - "dev": true, - "requires": { - "tslib": "^2.5.0" - } - }, "@types/node": { "version": "18.18.14", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", @@ -47443,12 +47488,6 @@ "nise": "^5.1.4", "supports-color": "^7.2.0" } - }, - "typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", - "dev": true } } }, @@ -47460,6 +47499,7 @@ "@opentelemetry/api": "^1.3.0", "@opentelemetry/api-events": "^0.57.2", "@opentelemetry/api-logs": "^0.57.2", + "@opentelemetry/core": "^1.30.1", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/sdk-events": "^0.57.2", "@opentelemetry/sdk-logs": "^0.57.2", @@ -47476,7 +47516,7 @@ "@web/test-runner": "^0.18.0", "chai": "^4.3.10", "sinon": "15.2.0", - "typescript": "4.4.4" + "typescript": "^5.0.4" }, "dependencies": { "@babel/core": { @@ -47502,6 +47542,79 @@ "semver": "^6.3.1" } }, + "@opentelemetry/api-logs": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.57.2.tgz", + "integrity": "sha512-uIX52NnTM0iBh84MShlpouI7UKqkZ7MrUszTmaypHBu4r7NofznSnQRfJ+uUeDtQDj6w8eFGg5KBLDAwAPz1+A==", + "requires": { + "@opentelemetry/api": "^1.3.0" + } + }, + "@opentelemetry/core": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.30.1.tgz", + "integrity": "sha512-OOCM2C/QIURhJMuKaekP3TRBxBKxG/TWWA0TL2J6nXUtDnuCtccy49LUJF8xPFXMX+0LMcxFpCo8M9cGY1W6rQ==", + "requires": { + "@opentelemetry/semantic-conventions": "1.28.0" + } + }, + "@opentelemetry/instrumentation": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.57.2.tgz", + "integrity": "sha512-BdBGhQBh8IjZ2oIIX6F2/Q3LKm/FDDKi6ccYKcBTeilh6SNdNKveDOLk73BkSJjQLJk6qe4Yh+hHw1UPhCDdrg==", + "requires": { + "@opentelemetry/api-logs": "0.57.2", + "@types/shimmer": "^1.2.0", + "import-in-the-middle": "^1.8.1", + "require-in-the-middle": "^7.1.1", + "semver": "^7.5.2", + "shimmer": "^1.2.1" + }, + "dependencies": { + "semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==" + } + } + }, + "@opentelemetry/resources": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.30.1.tgz", + "integrity": "sha512-5UxZqiAgLYGFjS4s9qm5mBVo433u+dSPUFWVWXmLAD4wB65oMCoXaJP1KJa9DIYYMeHu3z4BZcStG3LC593cWA==", + "dev": true, + "requires": { + "@opentelemetry/core": "1.30.1", + "@opentelemetry/semantic-conventions": "1.28.0" + } + }, + "@opentelemetry/sdk-logs": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.57.2.tgz", + "integrity": "sha512-TXFHJ5c+BKggWbdEQ/inpgIzEmS2BGQowLE9UhsMd7YYlUfBQJ4uax0VF/B5NYigdM/75OoJGhAV3upEhK+3gg==", + "dev": true, + "requires": { + "@opentelemetry/api-logs": "0.57.2", + "@opentelemetry/core": "1.30.1", + "@opentelemetry/resources": "1.30.1" + } + }, + "@opentelemetry/sdk-trace-base": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.30.1.tgz", + "integrity": "sha512-jVPgBbH1gCy2Lb7X0AVQ8XAfgg0pJ4nvl8/IiQA6nxOsPvS+0zMJaFSs2ltXe0J6C8dqjcnpyqINDJmU30+uOg==", + "dev": true, + "requires": { + "@opentelemetry/core": "1.30.1", + "@opentelemetry/resources": "1.30.1", + "@opentelemetry/semantic-conventions": "1.28.0" + } + }, + "@opentelemetry/semantic-conventions": { + "version": "1.28.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.28.0.tgz", + "integrity": "sha512-lp4qAiMTD4sNWW4DbKLBkfiMZ4jbAboJIGOQr5DvciMRI494OapieI9qiODpOt0XBr1LjIDy1xAGAnVs5supTA==" + }, "@types/node": { "version": "18.18.14", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", @@ -47511,6 +47624,11 @@ "undici-types": "~5.26.4" } }, + "@types/shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==" + }, "convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", @@ -47522,12 +47640,6 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true - }, - "typescript": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz", - "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==", - "dev": true } } }, @@ -67849,4 +67961,4 @@ "integrity": "sha512-9oxn0IIjbCZkJ67L+LkhYWRyAy7axphb3VgE2MBDlOqnmHMPWGYMxJxBYFueFq/JGY2GMwS0rU+UCLunEmy5UA==" } } -} \ No newline at end of file +} diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/package.json b/plugins/web/opentelemetry-instrumentation-web-exception/package.json index f83f9fe281..c7c12fa0ea 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/package.json +++ b/plugins/web/opentelemetry-instrumentation-web-exception/package.json @@ -25,12 +25,14 @@ "exception", "web", "tracing", - "plugin" + "plugin", + "browser", + "error" ], "author": "OpenTelemetry Authors", "license": "Apache-2.0", "engines": { - "node": ">=14" + "node": "^18.19.0 || >=20.6.0" }, "files": [ "build/esm/**/*.js", @@ -68,10 +70,11 @@ "@web/test-runner": "^0.18.0", "chai": "^4.3.10", "sinon": "15.2.0", - "typescript": "4.4.4" + "typescript": "^5.0.4" }, "dependencies": { "@opentelemetry/api-events": "^0.57.2", + "@opentelemetry/core": "^1.30.1", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/semantic-conventions": "^1.27.0" }, From 88c984780a2861782ee1549fa86f492f33fd2d1a Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Tue, 22 Apr 2025 11:37:33 -0400 Subject: [PATCH 16/38] add to release please --- .release-please-manifest.json | 1 + .../package.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b2c4704a6f..52122c2883 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -60,6 +60,7 @@ "plugins/web/opentelemetry-instrumentation-long-task": "0.45.0", "plugins/web/opentelemetry-instrumentation-user-interaction": "0.45.0", "plugins/web/opentelemetry-plugin-react-load": "0.32.0", + "plugins/web/opentelemetry-instrumentation-web-exception": "0.0.1", "propagators/opentelemetry-propagator-instana": "0.4.0", "propagators/opentelemetry-propagator-ot-trace": "0.28.0", "propagators/propagator-aws-xray": "2.0.0", diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json index 526dd9af64..88b7de7bfe 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json @@ -75,7 +75,7 @@ "typescript": "5.0.4", "webpack": "5.94.0", "webpack-cli": "5.1.4", - "webpack-merge": "5.10.0", + "webpack-merge": "20.6.0", "zone.js": "^0.11.4 || ^0.13.0 || ^0.14.0 || ^0.15.0" }, "dependencies": { @@ -89,4 +89,4 @@ }, "sideEffects": false, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-user-interaction#readme" -} +} \ No newline at end of file From acc48031f57214e263799086b1e516b3f368581d Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Tue, 22 Apr 2025 11:42:49 -0400 Subject: [PATCH 17/38] undo typo --- .../opentelemetry-instrumentation-user-interaction/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json index 88b7de7bfe..48c2fa2fd6 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json @@ -75,7 +75,7 @@ "typescript": "5.0.4", "webpack": "5.94.0", "webpack-cli": "5.1.4", - "webpack-merge": "20.6.0", + "webpack-merge": "5.10.0", "zone.js": "^0.11.4 || ^0.13.0 || ^0.14.0 || ^0.15.0" }, "dependencies": { From f1f5b0695c09bf7682de4cd81dae400f09690ebf Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Tue, 22 Apr 2025 13:36:23 -0400 Subject: [PATCH 18/38] fix ts issue in test --- .../test/instrumentation.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts index fb386f627f..384be99f19 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts @@ -38,7 +38,7 @@ describe('WebExceptionInstrumentation', () => { const logRecordProcessor = new SimpleLogRecordProcessor(exporter); loggerProvider.addLogRecordProcessor(logRecordProcessor); - const eventLoggerProvider = new EventLoggerProvider(loggerProvider); + const eventLoggerProvider = new EventLoggerProvider(loggerProvider as any); events.setGlobalEventLoggerProvider(eventLoggerProvider); // Helper function to throw an error of a specific type so that we can allow the error to propagate and test the instrumentation. From bdec0a0c959c65ed75e34171771fe93d70fe2c11 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Tue, 3 Jun 2025 11:52:29 -0400 Subject: [PATCH 19/38] handle strings --- .../src/instrumentation.ts | 30 ++++++++++--- .../test/instrumentation.test.ts | 45 +++++++++++++++++-- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index c07f5b9783..ea42cca040 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -51,8 +51,31 @@ export class WebExceptionInstrumentation extends InstrumentationBase { + const EXCEPTION_EVENT_NAME = 'exception'; const error: Error | undefined = 'reason' in event ? event.reason : event.error; + + const eventLogger = events.getEventLogger( + this.instrumentationName, + this.instrumentationVersion + ); + + if (typeof error === 'string') { + const customAttributes = this.applyCustomAttributes + ? this.applyCustomAttributes(error) + : {}; + + eventLogger.emit({ + name: EXCEPTION_EVENT_NAME, + data: { + [ATTR_EXCEPTION_MESSAGE]: error, + }, + attributes: customAttributes, + severityNumber: SeverityNumber.ERROR, + timestamp: hrTime(), + }); + } + if (error) { const message = error.message; const type = error.name; @@ -62,17 +85,12 @@ export class WebExceptionInstrumentation extends InstrumentationBase { source?: string, lineno?: number, colno?: number, - error?: Error + error?: Error | string ) => { - if (error?.name !== 'ValidationError') { + console.log(error); + if (error instanceof Error && error.name !== 'ValidationError') { // If we are testing our instrumentation, we want to let the error propagate. // If it is any other kind of error, we want Mocha to handle the error as expected. mochaErrorHandler?.call(window, event, source, lineno, colno, error); } + + if (typeof error === 'string' && error !== 'string') { + // If we are testing our instrumentation, we want to let the error propagate. + // If it is any other kind of error, we want Mocha to handle the error as expected. + mochaErrorHandler?.call(window, event, source, lineno, colno); + } }; }); @@ -140,10 +147,27 @@ describe('WebExceptionInstrumentation', () => { assert.strictEqual(body[ATTR_EXCEPTION_STACKTRACE], stack); }, 0); }); + + it('should handle throwing an error as a string', async () => { + setTimeout(() => { + throw 'string'; + }); + + setTimeout(() => { + const events = exporter.getFinishedLogRecords(); + // assert.ok(events.length > 0, 'Expected at least one log record'); + const event = events[0]; + const body = event.body as Record; + assert.strictEqual(body[ATTR_EXCEPTION_MESSAGE], 'string'); + }, 0); + }); }); describe('adding custom attributes', () => { - const applyCustomAttrs = (error: Error) => { + const applyCustomAttrs = (error: Error | string) => { + if (typeof error === 'string') { + return { 'app.custom.exception': error.toLocaleUpperCase() }; + } return { 'app.custom.exception': error.message.toLocaleUpperCase(), }; @@ -178,5 +202,20 @@ describe('WebExceptionInstrumentation', () => { ); }, 0); }); + + it('should add custom attributes if the error is a string', async () => { + setTimeout(() => { + throw 'string'; + }); + + setTimeout(() => { + const events = exporter.getFinishedLogRecords(); + assert.ok(events.length > 0, 'Expected at least one log record'); + const event = events[0]; + const body = event.body as Record; + assert.strictEqual(body[ATTR_EXCEPTION_MESSAGE], 'string'); + assert.strictEqual(event.attributes['app.custom.exception'], 'STRING'); + }, 0); + }); }); }); From 53f9e08d5f69a9d966a5efcfeb0ba1331c3607d8 Mon Sep 17 00:00:00 2001 From: Purvi Kanal Date: Tue, 3 Jun 2025 11:53:48 -0400 Subject: [PATCH 20/38] don't use an arrow function --- .../src/instrumentation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts index ea42cca040..768d064d16 100644 --- a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts @@ -50,7 +50,7 @@ export class WebExceptionInstrumentation extends InstrumentationBase { + onError(event: ErrorEvent | PromiseRejectionEvent) { const EXCEPTION_EVENT_NAME = 'exception'; const error: Error | undefined = 'reason' in event ? event.reason : event.error; @@ -97,7 +97,7 @@ export class WebExceptionInstrumentation extends InstrumentationBase Date: Thu, 30 Oct 2025 12:51:40 -0500 Subject: [PATCH 21/38] move plugins/web/opentelemetry-instrumentation-web-exception/ -> packages/opentelemetry-instrumentation-web/ --- .../opentelemetry-instrumentation-web-exception/.eslintignore | 0 .../opentelemetry-instrumentation-web-exception/.eslintrc.js | 0 .../opentelemetry-instrumentation-web-exception/CHANGELOG.md | 0 .../opentelemetry-instrumentation-web-exception/LICENSE | 0 .../opentelemetry-instrumentation-web-exception/README.md | 0 .../opentelemetry-instrumentation-web-exception/package.json | 0 .../opentelemetry-instrumentation-web-exception/src/index.ts | 0 .../src/instrumentation.ts | 0 .../test/instrumentation.test.ts | 0 .../opentelemetry-instrumentation-web-exception/tsconfig.esm.json | 0 .../tsconfig.esnext.json | 0 .../opentelemetry-instrumentation-web-exception/tsconfig.json | 0 .../web-test-runner.config.mjs | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/.eslintignore (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/.eslintrc.js (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/CHANGELOG.md (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/LICENSE (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/README.md (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/package.json (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/src/index.ts (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/src/instrumentation.ts (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/tsconfig.esm.json (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/tsconfig.json (100%) rename {plugins/web => packages}/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs (100%) diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/.eslintignore b/packages/opentelemetry-instrumentation-web-exception/.eslintignore similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/.eslintignore rename to packages/opentelemetry-instrumentation-web-exception/.eslintignore diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/.eslintrc.js b/packages/opentelemetry-instrumentation-web-exception/.eslintrc.js similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/.eslintrc.js rename to packages/opentelemetry-instrumentation-web-exception/.eslintrc.js diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/CHANGELOG.md b/packages/opentelemetry-instrumentation-web-exception/CHANGELOG.md similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/CHANGELOG.md rename to packages/opentelemetry-instrumentation-web-exception/CHANGELOG.md diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/LICENSE b/packages/opentelemetry-instrumentation-web-exception/LICENSE similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/LICENSE rename to packages/opentelemetry-instrumentation-web-exception/LICENSE diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/README.md b/packages/opentelemetry-instrumentation-web-exception/README.md similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/README.md rename to packages/opentelemetry-instrumentation-web-exception/README.md diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/package.json b/packages/opentelemetry-instrumentation-web-exception/package.json similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/package.json rename to packages/opentelemetry-instrumentation-web-exception/package.json diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/index.ts b/packages/opentelemetry-instrumentation-web-exception/src/index.ts similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/src/index.ts rename to packages/opentelemetry-instrumentation-web-exception/src/index.ts diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/packages/opentelemetry-instrumentation-web-exception/src/instrumentation.ts similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/src/instrumentation.ts rename to packages/opentelemetry-instrumentation-web-exception/src/instrumentation.ts diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/packages/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts rename to packages/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esm.json b/packages/opentelemetry-instrumentation-web-exception/tsconfig.esm.json similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esm.json rename to packages/opentelemetry-instrumentation-web-exception/tsconfig.esm.json diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json b/packages/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json rename to packages/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.json b/packages/opentelemetry-instrumentation-web-exception/tsconfig.json similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/tsconfig.json rename to packages/opentelemetry-instrumentation-web-exception/tsconfig.json diff --git a/plugins/web/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs b/packages/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs similarity index 100% rename from plugins/web/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs rename to packages/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs From a8d3d7761d6d1093949fcb216fe65baf3ac29e9f Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 12:54:39 -0500 Subject: [PATCH 22/38] Update release-please-* to include instrumentation-web-exception --- .release-please-manifest.json | 1 + release-please-config.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0a774e6f9d..1166ce336f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -62,6 +62,7 @@ "packages/instrumentation-document-load": "0.53.0", "packages/instrumentation-long-task": "0.52.0", "packages/instrumentation-user-interaction": "0.52.0", + "packages/instrumentation-web-exception": "0.0.1", "packages/plugin-react-load": "0.39.0", "packages/propagator-instana": "0.4.3", "packages/propagator-ot-trace": "0.28.3", diff --git a/release-please-config.json b/release-please-config.json index 3b1e3943d4..76fa13d14d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -69,6 +69,7 @@ "packages/instrumentation-document-load": {}, "packages/instrumentation-long-task": {}, "packages/instrumentation-user-interaction": {}, + "packages/instrumentation-web-exception": {}, "packages/plugin-react-load": {}, "packages/propagator-instana": {}, "packages/propagator-ot-trace": {}, From 6109947b9e8bfa9187ba33dbe8ecb4a160b44bdf Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 13:57:14 -0500 Subject: [PATCH 23/38] Add codeowners for instrumentation-web-exception instrumentation. --- .github/component-label-map.yml | 4 ++++ .github/component_owners.yml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/.github/component-label-map.yml b/.github/component-label-map.yml index b25b55e78c..ee920923ff 100644 --- a/.github/component-label-map.yml +++ b/.github/component-label-map.yml @@ -245,6 +245,10 @@ pkg:instrumentation-user-interaction: - changed-files: - any-glob-to-any-file: - packages/instrumentation-user-interaction/** +pkg:instrumentation-web-exception: + - changed-files: + - any-glob-to-any-file: + - packages/instrumentation-web-exception/** pkg:instrumentation-winston: - changed-files: - any-glob-to-any-file: diff --git a/.github/component_owners.yml b/.github/component_owners.yml index 85120136a8..cb179e8645 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -156,6 +156,9 @@ components: - t2t2 packages/instrumentation-user-interaction: - obecny + packages/instrumentation-web-exception: + - martinkuba + - wolfgangcodes packages/plugin-react-load: - martinkuba packages/propagator-instana: From 3e954047db0660e674d4c91aa534de481f2e74bf Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 14:00:03 -0500 Subject: [PATCH 24/38] Omit redundant prefix opentelemetry- --- .../.eslintignore | 0 .../.eslintrc.js | 0 .../CHANGELOG.md | 0 .../LICENSE | 0 .../README.md | 0 .../package.json | 0 .../src/index.ts | 0 .../src/instrumentation.ts | 0 .../test/instrumentation.test.ts | 0 .../tsconfig.esm.json | 0 .../tsconfig.esnext.json | 0 .../tsconfig.json | 0 .../web-test-runner.config.mjs | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/.eslintignore (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/.eslintrc.js (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/CHANGELOG.md (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/LICENSE (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/README.md (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/package.json (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/src/index.ts (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/src/instrumentation.ts (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/test/instrumentation.test.ts (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/tsconfig.esm.json (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/tsconfig.esnext.json (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/tsconfig.json (100%) rename packages/{opentelemetry-instrumentation-web-exception => instrumentation-web-exception}/web-test-runner.config.mjs (100%) diff --git a/packages/opentelemetry-instrumentation-web-exception/.eslintignore b/packages/instrumentation-web-exception/.eslintignore similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/.eslintignore rename to packages/instrumentation-web-exception/.eslintignore diff --git a/packages/opentelemetry-instrumentation-web-exception/.eslintrc.js b/packages/instrumentation-web-exception/.eslintrc.js similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/.eslintrc.js rename to packages/instrumentation-web-exception/.eslintrc.js diff --git a/packages/opentelemetry-instrumentation-web-exception/CHANGELOG.md b/packages/instrumentation-web-exception/CHANGELOG.md similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/CHANGELOG.md rename to packages/instrumentation-web-exception/CHANGELOG.md diff --git a/packages/opentelemetry-instrumentation-web-exception/LICENSE b/packages/instrumentation-web-exception/LICENSE similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/LICENSE rename to packages/instrumentation-web-exception/LICENSE diff --git a/packages/opentelemetry-instrumentation-web-exception/README.md b/packages/instrumentation-web-exception/README.md similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/README.md rename to packages/instrumentation-web-exception/README.md diff --git a/packages/opentelemetry-instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/package.json rename to packages/instrumentation-web-exception/package.json diff --git a/packages/opentelemetry-instrumentation-web-exception/src/index.ts b/packages/instrumentation-web-exception/src/index.ts similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/src/index.ts rename to packages/instrumentation-web-exception/src/index.ts diff --git a/packages/opentelemetry-instrumentation-web-exception/src/instrumentation.ts b/packages/instrumentation-web-exception/src/instrumentation.ts similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/src/instrumentation.ts rename to packages/instrumentation-web-exception/src/instrumentation.ts diff --git a/packages/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts b/packages/instrumentation-web-exception/test/instrumentation.test.ts similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/test/instrumentation.test.ts rename to packages/instrumentation-web-exception/test/instrumentation.test.ts diff --git a/packages/opentelemetry-instrumentation-web-exception/tsconfig.esm.json b/packages/instrumentation-web-exception/tsconfig.esm.json similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/tsconfig.esm.json rename to packages/instrumentation-web-exception/tsconfig.esm.json diff --git a/packages/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json b/packages/instrumentation-web-exception/tsconfig.esnext.json similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/tsconfig.esnext.json rename to packages/instrumentation-web-exception/tsconfig.esnext.json diff --git a/packages/opentelemetry-instrumentation-web-exception/tsconfig.json b/packages/instrumentation-web-exception/tsconfig.json similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/tsconfig.json rename to packages/instrumentation-web-exception/tsconfig.json diff --git a/packages/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs b/packages/instrumentation-web-exception/web-test-runner.config.mjs similarity index 100% rename from packages/opentelemetry-instrumentation-web-exception/web-test-runner.config.mjs rename to packages/instrumentation-web-exception/web-test-runner.config.mjs From b7112c80f1d1ec7bfbb45073e885390bed0462ad Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 17:45:53 -0500 Subject: [PATCH 25/38] Fix path to tsconfig. --- packages/instrumentation-web-exception/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/instrumentation-web-exception/tsconfig.json b/packages/instrumentation-web-exception/tsconfig.json index 28be80d266..4078877ce6 100644 --- a/packages/instrumentation-web-exception/tsconfig.json +++ b/packages/instrumentation-web-exception/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.base", + "extends": "../../tsconfig.base", "compilerOptions": { "rootDir": ".", "outDir": "build" From ed6ff411644cf4b3d2e5bdc016b9b1abd038fceb Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 18:20:17 -0500 Subject: [PATCH 26/38] Remove events package. --- package-lock.json | 307 +++++++++++++++--- .../package.json | 6 +- 2 files changed, 265 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index 02236413db..876482f66d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2282,7 +2282,6 @@ "integrity": "sha512-qAHSfAdVyFmIvl0VHELib8xar7ONuSHrE2hLnsaWkYNTI68dmi1x8GYDhJjMI/e7XWal9QBlZkwbOnkcw7Z8gQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.6", @@ -4172,7 +4171,6 @@ "integrity": "sha512-b7W4snvXYi1T2puUjxamASCCNhNzVSzb/fQUuGSkdjm/AFfJ24jo8kOHQyOcaoArCG71sVQci4vkZaITzl/V1w==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@cucumber/ci-environment": "10.0.1", "@cucumber/cucumber-expressions": "18.0.1", @@ -4254,7 +4252,6 @@ "integrity": "sha512-659CCFsrsyvuBi/Eix1fnhSheMnojSfnBcqJ3IMPNawx7JlrNJDcXYSSdxcUw3n/nG05P+ptCjmiZY3i14p+tA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@cucumber/messages": ">=19.1.4 <29" } @@ -4411,7 +4408,6 @@ "integrity": "sha512-Kxap9uP5jD8tHUZVjTWgzxemi/0uOsbGjd4LBOSxcJoOCRbESFwemUzilJuzNTB8pcTQUh8D5oudUyxfkJOKmA==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { "@cucumber/messages": ">=17.1.1" } @@ -4422,7 +4418,6 @@ "integrity": "sha512-2LzZtOwYKNlCuNf31ajkrekoy2M4z0Z1QGiPH40n4gf5t8VOUFb7m1ojtR4LmGvZxBGvJZP8voOmRqDWzBzYKA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/uuid": "10.0.0", "class-transformer": "0.5.1", @@ -7344,7 +7339,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "@napi-rs/wasm-runtime": "0.2.4", "@yarnpkg/lockfile": "^1.1.0", @@ -7646,7 +7640,6 @@ "integrity": "sha512-pzGXp14KF2Q4CDZGQgPK4l8zEg7i6cNkb+10yc8ZA5K41cLe3ZbWW1YxtY2e/glHauOJwTLSVjH4tiRVtOTizg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "iterare": "1.2.1", "tslib": "2.8.1", @@ -7729,7 +7722,6 @@ "integrity": "sha512-UVSf0yaWFBC2Zn2FOWABXxCnyG8XNIXrNnvTFpbUFqaJu1YDdwJ7wQBBqxq9CtJT7ILqSmfhOU7HS0d/0EAxpw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cors": "2.8.5", "express": "5.0.1", @@ -9197,7 +9189,6 @@ "integrity": "sha512-/g2d4sW9nUDJOMz3mabVQvOGhVa4e/BN/Um7yca9Bb2XTzPPnfTWHWQg+IsEYO7M3Vx+EXvaM/I2pJWIMun1bg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.1.0", @@ -9386,7 +9377,6 @@ "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=8.0.0" } @@ -9946,6 +9936,10 @@ "resolved": "packages/instrumentation-user-interaction", "link": true }, + "node_modules/@opentelemetry/instrumentation-web-exception": { + "resolved": "packages/instrumentation-web-exception", + "link": true + }, "node_modules/@opentelemetry/instrumentation-winston": { "resolved": "packages/instrumentation-winston", "link": true @@ -10424,7 +10418,6 @@ "integrity": "sha512-MZVUE+l7LmMIYlIjubPosruJ9ltSLGFmJqsXApTqPLyHLjsJUSAbAJb/A3N34fEqean4ddiDkdWzNu4ZKPvRUg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cluster-key-slot": "1.1.2" }, @@ -12461,7 +12454,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.9.tgz", "integrity": "sha512-5yBtK0k/q8PjkMXbTfeIEP/XVYnz1R9qZJ3yUicdEW7ppdDJfe+MqXEhpqDL3mtn4Wvs1u0KLEG0RXzCgNpsSg==", "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~6.21.0" } @@ -12543,7 +12535,6 @@ "integrity": "sha512-I98SaDCar5lvEYl80ClRIUztH/hyWHR+I2f+5yTVp/MQ205HgYkA2b5mVdry/+nsEIrf8I65KA5V/PASx68MsQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "^0.16", @@ -12813,7 +12804,6 @@ "integrity": "sha512-gTtSdWX9xiMPA/7MV9STjJOOYtWwIJIYxkQxnSV1U3xcE+mnJSH3f6zI0RYP+ew66WSlZ5ed+h0VCxsvdC1jJg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.41.0", "@typescript-eslint/types": "8.41.0", @@ -13861,7 +13851,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -13978,7 +13967,6 @@ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -14814,7 +14802,6 @@ "integrity": "sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/runtime": "^7.12.5", "cosmiconfig": "^7.0.0", @@ -15388,7 +15375,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.9", "caniuse-lite": "^1.0.30001746", @@ -17455,8 +17441,7 @@ "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz", "integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==", "dev": true, - "license": "BSD-3-Clause", - "peer": true + "license": "BSD-3-Clause" }, "node_modules/di": { "version": "0.0.1", @@ -18287,7 +18272,6 @@ "integrity": "sha512-RNCHRX5EwdrESy3Jc9o8ie8Bog+PeYvvSR8sDGoZxNFTvZ4dlxUB3WzQ3bQMztFrSRODGrLLj8g6OFuGY/aiQg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -19831,7 +19815,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -20718,7 +20701,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -21545,7 +21527,6 @@ "version": "2.16.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", - "dev": true, "license": "MIT", "dependencies": { "hasown": "^2.0.2" @@ -22951,7 +22932,6 @@ "integrity": "sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@colors/colors": "1.5.0", "body-parser": "^1.19.0", @@ -24533,7 +24513,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "@napi-rs/wasm-runtime": "0.2.4", "@yarnpkg/lockfile": "^1.1.0", @@ -27964,7 +27943,6 @@ "dev": true, "hasInstallScript": true, "license": "MIT", - "peer": true, "dependencies": { "@napi-rs/wasm-runtime": "0.2.4", "@yarnpkg/lockfile": "^1.1.0", @@ -29316,7 +29294,6 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true, "license": "MIT" }, "node_modules/path-scurry": { @@ -29390,7 +29367,6 @@ "integrity": "sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "buffer-writer": "2.0.0", "packet-reader": "1.0.0", @@ -30236,7 +30212,6 @@ "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" @@ -30699,8 +30674,7 @@ "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", "dev": true, - "license": "Apache-2.0", - "peer": true + "license": "Apache-2.0" }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", @@ -30897,7 +30871,6 @@ "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", - "dev": true, "license": "MIT", "dependencies": { "is-core-module": "^2.16.0", @@ -31335,7 +31308,6 @@ "integrity": "sha512-CLEVl+MnPAiKh5pl4dEWSyMTpuflgNQiLGhMv8ezD5W/qP8AKvmYpCOKRRNOh7oRKnauBZ4SyeYkMS+1VSyKwQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -31455,7 +31427,6 @@ "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "tslib": "^2.1.0" } @@ -31645,7 +31616,6 @@ "version": "7.7.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -33578,7 +33548,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -33982,7 +33951,6 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -34588,7 +34556,6 @@ "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -35127,7 +35094,6 @@ "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -35686,7 +35652,6 @@ "integrity": "sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "^1.0.5", "@webassemblyjs/ast": "^1.12.1", @@ -35734,7 +35699,6 @@ "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", @@ -36681,8 +36645,7 @@ "version": "0.15.1", "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.15.1.tgz", "integrity": "sha512-XE96n56IQpJM7NAoXswY3XRLcWFW83xe0BiAOeMD7K5k5xecOeul3Qcpx6GqEeeHNkW5DWL5zOyTbEfB4eti8w==", - "license": "MIT", - "peer": true + "license": "MIT" }, "packages/auto-configuration-propagators": { "name": "@opentelemetry/auto-configuration-propagators", @@ -39847,6 +39810,262 @@ "dev": true, "license": "MIT" }, + "packages/instrumentation-web-exception": { + "name": "@opentelemetry/instrumentation-web-exception", + "version": "0.0.1", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "^0.207.0", + "@opentelemetry/core": "^1.30.1", + "@opentelemetry/instrumentation": "^0.57.2", + "@opentelemetry/semantic-conventions": "^1.27.0" + }, + "devDependencies": { + "@babel/core": "7.22.17", + "@jsdevtools/coverage-istanbul-loader": "3.0.5", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/sdk-logs": "^0.207.0", + "@opentelemetry/sdk-trace-base": "^1.0.0", + "@rollup/plugin-commonjs": "^26.0.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@types/chai": "^4.3.10", + "@types/mocha": "10.0.10", + "@types/node": "18.18.14", + "@types/sinon": "17.0.4", + "@web/dev-server-esbuild": "^1.0.1", + "@web/dev-server-rollup": "^0.6.1", + "@web/test-runner": "^0.18.0", + "chai": "^4.3.10", + "sinon": "15.2.0", + "typescript": "^5.0.4" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "packages/instrumentation-web-exception/node_modules/@babel/core": { + "version": "7.22.17", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.17.tgz", + "integrity": "sha512-2EENLmhpwplDux5PSsZnSbnSkB3tZ6QTksgO25xwEL7pIDcNOMhF5v/s6RzwjMZzZzw9Ofc30gHv5ChCC8pifQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.22.15", + "@babel/helper-compilation-targets": "^7.22.15", + "@babel/helper-module-transforms": "^7.22.17", + "@babel/helpers": "^7.22.15", + "@babel/parser": "^7.22.16", + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.22.17", + "@babel/types": "^7.22.17", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "packages/instrumentation-web-exception/node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "packages/instrumentation-web-exception/node_modules/@opentelemetry/core": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.30.1.tgz", + "integrity": "sha512-OOCM2C/QIURhJMuKaekP3TRBxBKxG/TWWA0TL2J6nXUtDnuCtccy49LUJF8xPFXMX+0LMcxFpCo8M9cGY1W6rQ==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.28.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "packages/instrumentation-web-exception/node_modules/@opentelemetry/instrumentation": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.57.2.tgz", + "integrity": "sha512-BdBGhQBh8IjZ2oIIX6F2/Q3LKm/FDDKi6ccYKcBTeilh6SNdNKveDOLk73BkSJjQLJk6qe4Yh+hHw1UPhCDdrg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "0.57.2", + "@types/shimmer": "^1.2.0", + "import-in-the-middle": "^1.8.1", + "require-in-the-middle": "^7.1.1", + "semver": "^7.5.2", + "shimmer": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "packages/instrumentation-web-exception/node_modules/@opentelemetry/instrumentation/node_modules/@opentelemetry/api-logs": { + "version": "0.57.2", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.57.2.tgz", + "integrity": "sha512-uIX52NnTM0iBh84MShlpouI7UKqkZ7MrUszTmaypHBu4r7NofznSnQRfJ+uUeDtQDj6w8eFGg5KBLDAwAPz1+A==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api": "^1.3.0" + }, + "engines": { + "node": ">=14" + } + }, + "packages/instrumentation-web-exception/node_modules/@opentelemetry/resources": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.30.1.tgz", + "integrity": "sha512-5UxZqiAgLYGFjS4s9qm5mBVo433u+dSPUFWVWXmLAD4wB65oMCoXaJP1KJa9DIYYMeHu3z4BZcStG3LC593cWA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "1.30.1", + "@opentelemetry/semantic-conventions": "1.28.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "packages/instrumentation-web-exception/node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.30.1.tgz", + "integrity": "sha512-jVPgBbH1gCy2Lb7X0AVQ8XAfgg0pJ4nvl8/IiQA6nxOsPvS+0zMJaFSs2ltXe0J6C8dqjcnpyqINDJmU30+uOg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "1.30.1", + "@opentelemetry/resources": "1.30.1", + "@opentelemetry/semantic-conventions": "1.28.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "packages/instrumentation-web-exception/node_modules/@opentelemetry/semantic-conventions": { + "version": "1.28.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.28.0.tgz", + "integrity": "sha512-lp4qAiMTD4sNWW4DbKLBkfiMZ4jbAboJIGOQr5DvciMRI494OapieI9qiODpOt0XBr1LjIDy1xAGAnVs5supTA==", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + } + }, + "packages/instrumentation-web-exception/node_modules/@rollup/plugin-node-resolve": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.1.tgz", + "integrity": "sha512-tgg6b91pAybXHJQMAAwW9VuWBO6Thi+q7BCNARLwSqlmsHz0XYURtGvh/AuwSADXSI4h/2uHbs7s4FzlZDGSGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "packages/instrumentation-web-exception/node_modules/@types/chai": { + "version": "4.3.20", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.20.tgz", + "integrity": "sha512-/pC9HAB5I/xMlc5FP77qjCnI16ChlJfW0tGa0IUcFn38VJrTV6DeZ60NU5KZBtaOZqjdpwTWohz5HU1RrhiYxQ==", + "dev": true, + "license": "MIT" + }, + "packages/instrumentation-web-exception/node_modules/@types/node": { + "version": "18.18.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.14.tgz", + "integrity": "sha512-iSOeNeXYNYNLLOMDSVPvIFojclvMZ/HDY2dU17kUlcsOsSQETbWIslJbYLZgA+ox8g2XQwSHKTkght1a5X26lQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "packages/instrumentation-web-exception/node_modules/@types/shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==", + "license": "MIT" + }, + "packages/instrumentation-web-exception/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true, + "license": "MIT" + }, + "packages/instrumentation-web-exception/node_modules/import-in-the-middle": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.15.0.tgz", + "integrity": "sha512-bpQy+CrsRmYmoPMAE/0G33iwRqwW4ouqdRg8jgbH3aKuCtOc8lxgmYXg2dMM92CRiGP660EtBcymH/eVUpCSaA==", + "license": "Apache-2.0", + "dependencies": { + "acorn": "^8.14.0", + "acorn-import-attributes": "^1.9.5", + "cjs-module-lexer": "^1.2.2", + "module-details-from-path": "^1.0.3" + } + }, + "packages/instrumentation-web-exception/node_modules/require-in-the-middle": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-7.5.2.tgz", + "integrity": "sha512-gAZ+kLqBdHarXB64XpAe2VCjB7rIRv+mU8tfRWziHRJ5umKsIHN2tLLv6EtMw7WCdP19S0ERVMldNvxYCHnhSQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "module-details-from-path": "^1.0.3", + "resolve": "^1.22.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "packages/instrumentation-web-exception/node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, "packages/instrumentation-winston": { "name": "@opentelemetry/instrumentation-winston", "version": "0.52.0", diff --git a/packages/instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json index c7c12fa0ea..f22c7d9e99 100644 --- a/packages/instrumentation-web-exception/package.json +++ b/packages/instrumentation-web-exception/package.json @@ -55,9 +55,7 @@ "@babel/core": "7.22.17", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.3.0", - "@opentelemetry/api-logs": "^0.57.2", - "@opentelemetry/sdk-events": "^0.57.2", - "@opentelemetry/sdk-logs": "^0.57.2", + "@opentelemetry/sdk-logs": "^0.207.0", "@opentelemetry/sdk-trace-base": "^1.0.0", "@rollup/plugin-commonjs": "^26.0.0", "@rollup/plugin-node-resolve": "^15.2.3", @@ -73,7 +71,7 @@ "typescript": "^5.0.4" }, "dependencies": { - "@opentelemetry/api-events": "^0.57.2", + "@opentelemetry/api-logs": "^0.207.0", "@opentelemetry/core": "^1.30.1", "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/semantic-conventions": "^1.27.0" From 8f29c11088a0fe6d14071045fc1c5b4c2976c6df Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 22:24:17 -0500 Subject: [PATCH 27/38] Use the logs API. --- .../.eslintrc.js | 18 +++- .../src/instrumentation.ts | 89 +++++++++---------- .../test/instrumentation.test.ts | 30 +++---- .../web-test-runner.config.mjs | 4 +- 4 files changed, 73 insertions(+), 68 deletions(-) diff --git a/packages/instrumentation-web-exception/.eslintrc.js b/packages/instrumentation-web-exception/.eslintrc.js index 6efcc3621d..e33930faae 100644 --- a/packages/instrumentation-web-exception/.eslintrc.js +++ b/packages/instrumentation-web-exception/.eslintrc.js @@ -1,3 +1,19 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + module.exports = { env: { mocha: true, @@ -5,5 +21,5 @@ module.exports = { browser: true, jquery: true, }, - ...require('../../../eslint.config.js'), + ...require('../../eslint.config.mjs'), }; diff --git a/packages/instrumentation-web-exception/src/instrumentation.ts b/packages/instrumentation-web-exception/src/instrumentation.ts index 768d064d16..50390734b9 100644 --- a/packages/instrumentation-web-exception/src/instrumentation.ts +++ b/packages/instrumentation-web-exception/src/instrumentation.ts @@ -16,87 +16,80 @@ import { InstrumentationBase, - InstrumentationConfig, + type InstrumentationConfig, } from '@opentelemetry/instrumentation'; import { ATTR_EXCEPTION_TYPE, ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, } from '@opentelemetry/semantic-conventions'; -// TODO: should events be imported or included as part of the instrumentation base class? -import { events } from '@opentelemetry/api-events'; -import { SeverityNumber } from '@opentelemetry/api-logs'; -import { Attributes } from '@opentelemetry/api'; +import type { Attributes } from '@opentelemetry/api'; +import { + SeverityNumber, + logs, + type LogRecord, + type AnyValueMap, +} from '@opentelemetry/api-logs'; import { hrTime } from '@opentelemetry/core'; export interface GlobalErrorsInstrumentationConfig extends InstrumentationConfig { /** - * A callback function for adding custom attributes to the span when an error is recorded. + * A callback function for adding custom attributes to the log event when an error is recorded. * * @param {Error} error - The error object that is being recorded. * @returns {Attributes} - The attributes to add to the span. */ - applyCustomAttributes?: (error: Error) => Attributes; + applyCustomAttributes?: (error: Error | string) => Attributes; } export class WebExceptionInstrumentation extends InstrumentationBase { - readonly applyCustomAttributes?: (error: Error) => Attributes; constructor(config: GlobalErrorsInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-web-exception', '0.0.1', config); - - this.applyCustomAttributes = config.applyCustomAttributes; + this.onError = this.onError.bind(this); } - init() {} + init() { } - onError(event: ErrorEvent | PromiseRejectionEvent) { + onError( event: ErrorEvent | PromiseRejectionEvent) { const EXCEPTION_EVENT_NAME = 'exception'; - const error: Error | undefined = + const error: Error | string | undefined = 'reason' in event ? event.reason : event.error; - const eventLogger = events.getEventLogger( - this.instrumentationName, - this.instrumentationVersion - ); + if (error === undefined) { + return; + } - if (typeof error === 'string') { - const customAttributes = this.applyCustomAttributes - ? this.applyCustomAttributes(error) - : {}; + const logger = logs + .getLoggerProvider() + .getLogger(this.instrumentationName, this.instrumentationVersion); - eventLogger.emit({ - name: EXCEPTION_EVENT_NAME, - data: { - [ATTR_EXCEPTION_MESSAGE]: error, - }, - attributes: customAttributes, - severityNumber: SeverityNumber.ERROR, - timestamp: hrTime(), - }); - } + const config = this.getConfig(); + const customAttributes = config.applyCustomAttributes + ? config.applyCustomAttributes(error) + : {}; - if (error) { - const message = error.message; - const type = error.name; - const errorAttributes = { - [ATTR_EXCEPTION_TYPE]: type, - [ATTR_EXCEPTION_MESSAGE]: message, + let errorAttributes: AnyValueMap = {}; + + if (typeof error === 'string') { + errorAttributes = { [ATTR_EXCEPTION_MESSAGE]: error }; + } else { + errorAttributes = { + [ATTR_EXCEPTION_TYPE]: error.name, + [ATTR_EXCEPTION_MESSAGE]: error.message, [ATTR_EXCEPTION_STACKTRACE]: error.stack, }; + } - const customAttributes = this.applyCustomAttributes - ? this.applyCustomAttributes(error) - : {}; + const errorLog: LogRecord = { + eventName: EXCEPTION_EVENT_NAME, + severityNumber: SeverityNumber.ERROR, + attributes: { ...errorAttributes, ...customAttributes }, + timestamp: hrTime(), + observedTimestamp: hrTime(), + }; - eventLogger.emit({ - name: EXCEPTION_EVENT_NAME, - data: errorAttributes, - attributes: customAttributes, - severityNumber: SeverityNumber.ERROR, - timestamp: hrTime(), - }); - } + logger.emit(errorLog); } override disable(): void { diff --git a/packages/instrumentation-web-exception/test/instrumentation.test.ts b/packages/instrumentation-web-exception/test/instrumentation.test.ts index 66a4029e61..73f0706491 100644 --- a/packages/instrumentation-web-exception/test/instrumentation.test.ts +++ b/packages/instrumentation-web-exception/test/instrumentation.test.ts @@ -17,29 +17,28 @@ import { WebExceptionInstrumentation } from '../src/instrumentation'; // @ts-expect-error: not an export, but we want the prebundled version import chai from 'chai/chai.js'; -import { EventLoggerProvider } from '@opentelemetry/sdk-events'; import { LoggerProvider, SimpleLogRecordProcessor, InMemoryLogRecordExporter, + type LoggerProviderConfig, } from '@opentelemetry/sdk-logs'; -import { events } from '@opentelemetry/api-events'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, } from '@opentelemetry/semantic-conventions'; +import { logs } from '@opentelemetry/api-logs'; const assert = chai.assert; describe('WebExceptionInstrumentation', () => { - const loggerProvider = new LoggerProvider(); + const config : LoggerProviderConfig = {} + config.processors const exporter = new InMemoryLogRecordExporter(); const logRecordProcessor = new SimpleLogRecordProcessor(exporter); - loggerProvider.addLogRecordProcessor(logRecordProcessor); - - const eventLoggerProvider = new EventLoggerProvider(loggerProvider as any); - events.setGlobalEventLoggerProvider(eventLoggerProvider); + const loggerProvider = new LoggerProvider({processors:[logRecordProcessor]}); + logs.setGlobalLoggerProvider(loggerProvider); // Helper function to throw an error of a specific type so that we can allow the error to propagate and test the instrumentation. const throwErr = (message: string, stack?: string): void => { @@ -121,7 +120,7 @@ describe('WebExceptionInstrumentation', () => { const events = exporter.getFinishedLogRecords(); assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - assert.strictEqual(event.attributes['event.name'], 'exception'); + assert.strictEqual(event.eventName, 'exception'); }, 0); }); @@ -141,10 +140,9 @@ describe('WebExceptionInstrumentation', () => { const events = exporter.getFinishedLogRecords(); assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - const body = event.body as Record; - assert.strictEqual(body[ATTR_EXCEPTION_MESSAGE], 'Something happened!'); - assert.strictEqual(body[ATTR_EXCEPTION_TYPE], 'ValidationError'); - assert.strictEqual(body[ATTR_EXCEPTION_STACKTRACE], stack); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], 'Something happened!'); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_TYPE], 'ValidationError'); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_STACKTRACE], stack); }, 0); }); @@ -155,10 +153,9 @@ describe('WebExceptionInstrumentation', () => { setTimeout(() => { const events = exporter.getFinishedLogRecords(); - // assert.ok(events.length > 0, 'Expected at least one log record'); + assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - const body = event.body as Record; - assert.strictEqual(body[ATTR_EXCEPTION_MESSAGE], 'string'); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], 'string'); }, 0); }); }); @@ -212,8 +209,7 @@ describe('WebExceptionInstrumentation', () => { const events = exporter.getFinishedLogRecords(); assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - const body = event.body as Record; - assert.strictEqual(body[ATTR_EXCEPTION_MESSAGE], 'string'); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], 'string'); assert.strictEqual(event.attributes['app.custom.exception'], 'STRING'); }, 0); }); diff --git a/packages/instrumentation-web-exception/web-test-runner.config.mjs b/packages/instrumentation-web-exception/web-test-runner.config.mjs index 1989a756fd..7130bd21fa 100644 --- a/packages/instrumentation-web-exception/web-test-runner.config.mjs +++ b/packages/instrumentation-web-exception/web-test-runner.config.mjs @@ -1,11 +1,11 @@ -/*! +/* * Copyright The OpenTelemetry Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, From 02f14ca8e5e91fb287f86e6b205487d93bef0d66 Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 22:50:50 -0500 Subject: [PATCH 28/38] cleanup readme. --- .../instrumentation-web-exception/README.md | 13 ++++++------- .../instrumentation-web-exception/package.json | 2 +- .../test/instrumentation.test.ts | 17 ++++++++--------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/instrumentation-web-exception/README.md b/packages/instrumentation-web-exception/README.md index 1e0faf2aab..cbc3080bf9 100644 --- a/packages/instrumentation-web-exception/README.md +++ b/packages/instrumentation-web-exception/README.md @@ -15,14 +15,13 @@ npm install --save @opentelemetry/instrumentation-web-exception ```typescript import { LoggerProvider } from '@opentelemetry/sdk-logs'; -import { EventLoggerProvider, events } from '@opentelemetry/api-events'; +import { logs } from '@opentelemetry/api-logs'; import { WebExceptionInstrumentation } from '@opentelemetry/instrumentation-web-exception'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; -// Set up the logger provider and event logger +// Set up the logger provider const loggerProvider = new LoggerProvider(); -const eventLoggerProvider = new EventLoggerProvider(loggerProvider); -events.setGlobalEventLoggerProvider(eventLoggerProvider); +logs.setGlobalLoggerProvider(loggerProvider); // Register the instrumentation registerInstrumentations({ @@ -30,7 +29,7 @@ registerInstrumentations({ new WebExceptionInstrumentation({ // Optional: customize attributes added to error events applyCustomAttributes: (error) => ({ - 'app.error.severity': error.name === 'ValidationError' ? 'warning' : 'error', + 'app.error.severity': error?.name === 'ValidationError' ? 'warning' : 'error', 'custom.correlation.id': window.correlationId, }), }), @@ -45,7 +44,7 @@ The instrumentation can be configured with the following options: | Option | Type | Description | | ------- | ---- | ----------- | | `enabled` | `boolean` | Whether to enable the instrumentation. Default: `true` | -| `applyCustomAttributes` | `(error: Error) => Attributes` | Optional callback to add custom attributes to error events | +| `applyCustomAttributes` | `(error: Error \| string) => Attributes` | Optional callback to add custom attributes to error events | ## Features @@ -53,7 +52,7 @@ The instrumentation can be configured with the following options: - Captures unhandled promise rejections - Records error name, message, and stack trace using OpenTelemetry semantic conventions - Supports custom attributes through configuration -- Integrates with OpenTelemetry Events API +- Integrates with OpenTelemetry Logs API ## Semantic Attributes diff --git a/packages/instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json index f22c7d9e99..66664d4169 100644 --- a/packages/instrumentation-web-exception/package.json +++ b/packages/instrumentation-web-exception/package.json @@ -76,5 +76,5 @@ "@opentelemetry/instrumentation": "^0.57.2", "@opentelemetry/semantic-conventions": "^1.27.0" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load#readme" + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-web-exception#readme" } diff --git a/packages/instrumentation-web-exception/test/instrumentation.test.ts b/packages/instrumentation-web-exception/test/instrumentation.test.ts index 73f0706491..8ce565d924 100644 --- a/packages/instrumentation-web-exception/test/instrumentation.test.ts +++ b/packages/instrumentation-web-exception/test/instrumentation.test.ts @@ -21,7 +21,6 @@ import { LoggerProvider, SimpleLogRecordProcessor, InMemoryLogRecordExporter, - type LoggerProviderConfig, } from '@opentelemetry/sdk-logs'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { @@ -32,9 +31,9 @@ import { import { logs } from '@opentelemetry/api-logs'; const assert = chai.assert; +const STRING_ERROR = "Some error string." + describe('WebExceptionInstrumentation', () => { - const config : LoggerProviderConfig = {} - config.processors const exporter = new InMemoryLogRecordExporter(); const logRecordProcessor = new SimpleLogRecordProcessor(exporter); const loggerProvider = new LoggerProvider({processors:[logRecordProcessor]}); @@ -74,7 +73,7 @@ describe('WebExceptionInstrumentation', () => { mochaErrorHandler?.call(window, event, source, lineno, colno, error); } - if (typeof error === 'string' && error !== 'string') { + if (typeof error === 'string' && error !== STRING_ERROR) { // If we are testing our instrumentation, we want to let the error propagate. // If it is any other kind of error, we want Mocha to handle the error as expected. mochaErrorHandler?.call(window, event, source, lineno, colno); @@ -148,14 +147,14 @@ describe('WebExceptionInstrumentation', () => { it('should handle throwing an error as a string', async () => { setTimeout(() => { - throw 'string'; + throw STRING_ERROR; }); setTimeout(() => { const events = exporter.getFinishedLogRecords(); assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], 'string'); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], STRING_ERROR); }, 0); }); }); @@ -202,15 +201,15 @@ describe('WebExceptionInstrumentation', () => { it('should add custom attributes if the error is a string', async () => { setTimeout(() => { - throw 'string'; + throw STRING_ERROR; }); setTimeout(() => { const events = exporter.getFinishedLogRecords(); assert.ok(events.length > 0, 'Expected at least one log record'); const event = events[0]; - assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], 'string'); - assert.strictEqual(event.attributes['app.custom.exception'], 'STRING'); + assert.strictEqual(event.attributes[ATTR_EXCEPTION_MESSAGE], STRING_ERROR); + assert.strictEqual(event.attributes['app.custom.exception'], STRING_ERROR.toLocaleUpperCase()); }, 0); }); }); From ddaf100f552cb4cf70b91c38041cafd111849d8b Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 23:05:13 -0500 Subject: [PATCH 29/38] Add processors to readme setup example. --- packages/instrumentation-web-exception/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/instrumentation-web-exception/README.md b/packages/instrumentation-web-exception/README.md index cbc3080bf9..c4f5a43f46 100644 --- a/packages/instrumentation-web-exception/README.md +++ b/packages/instrumentation-web-exception/README.md @@ -14,13 +14,15 @@ npm install --save @opentelemetry/instrumentation-web-exception ## Usage ```typescript -import { LoggerProvider } from '@opentelemetry/sdk-logs'; +import { LoggerProvider, SimpleLogRecordProcessor, ConsoleLogRecordExporter } from '@opentelemetry/sdk-logs'; import { logs } from '@opentelemetry/api-logs'; import { WebExceptionInstrumentation } from '@opentelemetry/instrumentation-web-exception'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; -// Set up the logger provider -const loggerProvider = new LoggerProvider(); +// Set up the logger provider with a processor +const loggerProvider = new LoggerProvider({ + processors: [new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())] +}); logs.setGlobalLoggerProvider(loggerProvider); // Register the instrumentation From a1efcd0a2e03e6311029dd03bf73b6c85d80393a Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 23:28:37 -0500 Subject: [PATCH 30/38] Cleanup scripts, readme. --- packages/instrumentation-web-exception/README.md | 2 ++ packages/instrumentation-web-exception/package.json | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/instrumentation-web-exception/README.md b/packages/instrumentation-web-exception/README.md index c4f5a43f46..1d1abd1e8d 100644 --- a/packages/instrumentation-web-exception/README.md +++ b/packages/instrumentation-web-exception/README.md @@ -3,6 +3,8 @@ [![NPM Published Version][npm-img]][npm-url] [![Apache License][license-image]][license-image] +[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @martinkuba @wolfgangcodes + This module provides automatic instrumentation for capturing unhandled exceptions and promise rejections in web applications. ## Installation diff --git a/packages/instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json index 66664d4169..64be17d5ce 100644 --- a/packages/instrumentation-web-exception/package.json +++ b/packages/instrumentation-web-exception/package.json @@ -9,15 +9,17 @@ "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json", + "compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-web-exception", + "compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "lint:readme": "node ../../../scripts/lint-readme.js", - "prewatch": "npm run precompile", - "version:update": "node ../../../scripts/version-update.js", - "compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "prepublishOnly": "npm run compile", + "prewatch": "npm run precompile", "tdd": "wtr --watch", + "test": "npm run test:browser", "test:browser": "wtr --coverage", + "version:update": "node ../../../scripts/version-update.js", "watch": "tsc --build -watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json" }, "keywords": [ From 9e628f47739219535707ae136c7cb890ecafe646 Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Thu, 30 Oct 2025 23:54:16 -0500 Subject: [PATCH 31/38] Linting, config fixes. --- packages/instrumentation-web-exception/.eslintrc.js | 1 - .../instrumentation-web-exception/test/instrumentation.test.ts | 2 +- packages/instrumentation-web-exception/tsconfig.esm.json | 2 +- packages/instrumentation-web-exception/tsconfig.esnext.json | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/instrumentation-web-exception/.eslintrc.js b/packages/instrumentation-web-exception/.eslintrc.js index e33930faae..571d6ec624 100644 --- a/packages/instrumentation-web-exception/.eslintrc.js +++ b/packages/instrumentation-web-exception/.eslintrc.js @@ -21,5 +21,4 @@ module.exports = { browser: true, jquery: true, }, - ...require('../../eslint.config.mjs'), }; diff --git a/packages/instrumentation-web-exception/test/instrumentation.test.ts b/packages/instrumentation-web-exception/test/instrumentation.test.ts index 8ce565d924..7c041e5cd6 100644 --- a/packages/instrumentation-web-exception/test/instrumentation.test.ts +++ b/packages/instrumentation-web-exception/test/instrumentation.test.ts @@ -31,7 +31,7 @@ import { import { logs } from '@opentelemetry/api-logs'; const assert = chai.assert; -const STRING_ERROR = "Some error string." +const STRING_ERROR = 'Some error string.' describe('WebExceptionInstrumentation', () => { const exporter = new InMemoryLogRecordExporter(); diff --git a/packages/instrumentation-web-exception/tsconfig.esm.json b/packages/instrumentation-web-exception/tsconfig.esm.json index 379f547a46..a94adff6aa 100644 --- a/packages/instrumentation-web-exception/tsconfig.esm.json +++ b/packages/instrumentation-web-exception/tsconfig.esm.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.base.esm.json", + "extends": "../../tsconfig.base.esm.json", "compilerOptions": { "rootDir": "src", "outDir": "build/esm", diff --git a/packages/instrumentation-web-exception/tsconfig.esnext.json b/packages/instrumentation-web-exception/tsconfig.esnext.json index cb78dd6ff3..65a918cf6b 100644 --- a/packages/instrumentation-web-exception/tsconfig.esnext.json +++ b/packages/instrumentation-web-exception/tsconfig.esnext.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.base.esnext.json", + "extends": "../../tsconfig.base.esnext.json", "compilerOptions": { "rootDir": "src", "outDir": "build/esnext", From 76d74adf05f0557837012a31f7b19ab674f6bb67 Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Fri, 31 Oct 2025 00:00:05 -0500 Subject: [PATCH 32/38] Fix scripts relative path depth. --- packages/instrumentation-web-exception/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json index 64be17d5ce..89f125b790 100644 --- a/packages/instrumentation-web-exception/package.json +++ b/packages/instrumentation-web-exception/package.json @@ -13,13 +13,13 @@ "compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", - "lint:readme": "node ../../../scripts/lint-readme.js", + "lint:readme": "node ../../scripts/lint-readme.js", "prepublishOnly": "npm run compile", "prewatch": "npm run precompile", "tdd": "wtr --watch", "test": "npm run test:browser", "test:browser": "wtr --coverage", - "version:update": "node ../../../scripts/version-update.js", + "version:update": "node ../../scripts/version-update.js", "watch": "tsc --build -watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json" }, "keywords": [ From 092a4d957b62baebda2bf475eb2d750cbc6386a1 Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Mon, 3 Nov 2025 09:57:05 -0600 Subject: [PATCH 33/38] Add pkanal as component owner. --- .github/component_owners.yml | 1 + packages/instrumentation-web-exception/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/component_owners.yml b/.github/component_owners.yml index cb179e8645..c5672ae1d7 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -158,6 +158,7 @@ components: - obecny packages/instrumentation-web-exception: - martinkuba + - pkanal - wolfgangcodes packages/plugin-react-load: - martinkuba diff --git a/packages/instrumentation-web-exception/README.md b/packages/instrumentation-web-exception/README.md index 1d1abd1e8d..0c7b0fb5e3 100644 --- a/packages/instrumentation-web-exception/README.md +++ b/packages/instrumentation-web-exception/README.md @@ -3,7 +3,7 @@ [![NPM Published Version][npm-img]][npm-url] [![Apache License][license-image]][license-image] -[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @martinkuba @wolfgangcodes +[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @martinkuba @wolfgangcodes @pkanal This module provides automatic instrumentation for capturing unhandled exceptions and promise rejections in web applications. From ade00813a82d59500faf40376fef13ad0021d3ea Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Mon, 3 Nov 2025 10:41:10 -0600 Subject: [PATCH 34/38] Cleanup lint scripts. --- .../.eslintignore | 1 - .../.eslintrc.js | 24 ------------------- .../package.json | 3 --- 3 files changed, 28 deletions(-) delete mode 100644 packages/instrumentation-web-exception/.eslintignore delete mode 100644 packages/instrumentation-web-exception/.eslintrc.js diff --git a/packages/instrumentation-web-exception/.eslintignore b/packages/instrumentation-web-exception/.eslintignore deleted file mode 100644 index 378eac25d3..0000000000 --- a/packages/instrumentation-web-exception/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/packages/instrumentation-web-exception/.eslintrc.js b/packages/instrumentation-web-exception/.eslintrc.js deleted file mode 100644 index 571d6ec624..0000000000 --- a/packages/instrumentation-web-exception/.eslintrc.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -module.exports = { - env: { - mocha: true, - commonjs: true, - browser: true, - jquery: true, - }, -}; diff --git a/packages/instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json index 89f125b790..aa60e2a38a 100644 --- a/packages/instrumentation-web-exception/package.json +++ b/packages/instrumentation-web-exception/package.json @@ -11,9 +11,6 @@ "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-web-exception", "compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json", - "lint": "eslint . --ext .ts", - "lint:fix": "eslint . --ext .ts --fix", - "lint:readme": "node ../../scripts/lint-readme.js", "prepublishOnly": "npm run compile", "prewatch": "npm run precompile", "tdd": "wtr --watch", From 77c700cd19afd6b55da1e5523264a7454bbfa72e Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Mon, 3 Nov 2025 12:32:40 -0600 Subject: [PATCH 35/38] rename export to ExceptionInstrumentation --- packages/instrumentation-web-exception/README.md | 6 +++--- .../src/instrumentation.ts | 2 +- .../test/instrumentation.test.ts | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/instrumentation-web-exception/README.md b/packages/instrumentation-web-exception/README.md index 0c7b0fb5e3..eeb5d97cdc 100644 --- a/packages/instrumentation-web-exception/README.md +++ b/packages/instrumentation-web-exception/README.md @@ -18,7 +18,7 @@ npm install --save @opentelemetry/instrumentation-web-exception ```typescript import { LoggerProvider, SimpleLogRecordProcessor, ConsoleLogRecordExporter } from '@opentelemetry/sdk-logs'; import { logs } from '@opentelemetry/api-logs'; -import { WebExceptionInstrumentation } from '@opentelemetry/instrumentation-web-exception'; +import { ExceptionInstrumentation } from '@opentelemetry/instrumentation-web-exception'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; // Set up the logger provider with a processor @@ -30,7 +30,7 @@ logs.setGlobalLoggerProvider(loggerProvider); // Register the instrumentation registerInstrumentations({ instrumentations: [ - new WebExceptionInstrumentation({ + new ExceptionInstrumentation({ // Optional: customize attributes added to error events applyCustomAttributes: (error) => ({ 'app.error.severity': error?.name === 'ValidationError' ? 'warning' : 'error', @@ -72,7 +72,7 @@ The following semantic attributes are added to each error event: ```typescript // Initialize the instrumentation -const exceptionInstrumentation = new WebExceptionInstrumentation({ +const exceptionInstrumentation = new ExceptionInstrumentation({ applyCustomAttributes: (error) => ({ 'error.category': error instanceof TypeError ? 'type_error' : 'runtime_error', 'app.version': '1.0.0', diff --git a/packages/instrumentation-web-exception/src/instrumentation.ts b/packages/instrumentation-web-exception/src/instrumentation.ts index 50390734b9..8370b3c6f1 100644 --- a/packages/instrumentation-web-exception/src/instrumentation.ts +++ b/packages/instrumentation-web-exception/src/instrumentation.ts @@ -43,7 +43,7 @@ export interface GlobalErrorsInstrumentationConfig applyCustomAttributes?: (error: Error | string) => Attributes; } -export class WebExceptionInstrumentation extends InstrumentationBase { +export class ExceptionInstrumentation extends InstrumentationBase { constructor(config: GlobalErrorsInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-web-exception', '0.0.1', config); this.onError = this.onError.bind(this); diff --git a/packages/instrumentation-web-exception/test/instrumentation.test.ts b/packages/instrumentation-web-exception/test/instrumentation.test.ts index 7c041e5cd6..a0a76efa85 100644 --- a/packages/instrumentation-web-exception/test/instrumentation.test.ts +++ b/packages/instrumentation-web-exception/test/instrumentation.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { WebExceptionInstrumentation } from '../src/instrumentation'; +import { ExceptionInstrumentation } from '../src/instrumentation'; // @ts-expect-error: not an export, but we want the prebundled version import chai from 'chai/chai.js'; import { @@ -33,7 +33,7 @@ const assert = chai.assert; const STRING_ERROR = 'Some error string.' -describe('WebExceptionInstrumentation', () => { +describe('ExceptionInstrumentation', () => { const exporter = new InMemoryLogRecordExporter(); const logRecordProcessor = new SimpleLogRecordProcessor(exporter); const loggerProvider = new LoggerProvider({processors:[logRecordProcessor]}); @@ -88,15 +88,15 @@ describe('WebExceptionInstrumentation', () => { describe('constructor', () => { it('should construct an instance', () => { - const instrumentation = new WebExceptionInstrumentation({ + const instrumentation = new ExceptionInstrumentation({ enabled: false, }); - assert.ok(instrumentation instanceof WebExceptionInstrumentation); + assert.ok(instrumentation instanceof ExceptionInstrumentation); }); }); describe('throwing an error', () => { - const instr = new WebExceptionInstrumentation(); + const instr = new ExceptionInstrumentation(); beforeEach(() => { registerInstrumentations({ instrumentations: [instr], @@ -168,7 +168,7 @@ describe('WebExceptionInstrumentation', () => { 'app.custom.exception': error.message.toLocaleUpperCase(), }; }; - const instr = new WebExceptionInstrumentation({ + const instr = new ExceptionInstrumentation({ applyCustomAttributes: applyCustomAttrs, }); beforeEach(() => { From 2f62ac6fb3c7f6f3f483d16a531645c45209d9db Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Mon, 3 Nov 2025 12:38:11 -0600 Subject: [PATCH 36/38] Update version to 0.1.0, use version constants. --- packages/instrumentation-web-exception/package.json | 2 +- packages/instrumentation-web-exception/src/instrumentation.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/instrumentation-web-exception/package.json b/packages/instrumentation-web-exception/package.json index aa60e2a38a..43061e7b16 100644 --- a/packages/instrumentation-web-exception/package.json +++ b/packages/instrumentation-web-exception/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-web-exception", - "version": "0.0.1", + "version": "0.1.0", "description": "OpenTelemetry instrumentation for web exceptions", "main": "build/src/index.js", "module": "build/esm/index.js", diff --git a/packages/instrumentation-web-exception/src/instrumentation.ts b/packages/instrumentation-web-exception/src/instrumentation.ts index 8370b3c6f1..bce8fc34f5 100644 --- a/packages/instrumentation-web-exception/src/instrumentation.ts +++ b/packages/instrumentation-web-exception/src/instrumentation.ts @@ -31,6 +31,7 @@ import { type AnyValueMap, } from '@opentelemetry/api-logs'; import { hrTime } from '@opentelemetry/core'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; export interface GlobalErrorsInstrumentationConfig extends InstrumentationConfig { @@ -45,7 +46,7 @@ export interface GlobalErrorsInstrumentationConfig export class ExceptionInstrumentation extends InstrumentationBase { constructor(config: GlobalErrorsInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-web-exception', '0.0.1', config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); this.onError = this.onError.bind(this); } From b19a33fa298d303153f4f05fd3451ef5e09d4685 Mon Sep 17 00:00:00 2001 From: Wolfgang Therrien Date: Mon, 3 Nov 2025 13:39:04 -0500 Subject: [PATCH 37/38] Update packages/instrumentation-web-exception/src/instrumentation.ts Co-authored-by: Jared Freeze --- packages/instrumentation-web-exception/src/instrumentation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/instrumentation-web-exception/src/instrumentation.ts b/packages/instrumentation-web-exception/src/instrumentation.ts index bce8fc34f5..1eec4a74ac 100644 --- a/packages/instrumentation-web-exception/src/instrumentation.ts +++ b/packages/instrumentation-web-exception/src/instrumentation.ts @@ -52,7 +52,7 @@ export class ExceptionInstrumentation extends InstrumentationBase Date: Fri, 7 Nov 2025 21:50:44 -0600 Subject: [PATCH 38/38] Add knipignore to version import. --- packages/instrumentation-web-exception/src/instrumentation.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/instrumentation-web-exception/src/instrumentation.ts b/packages/instrumentation-web-exception/src/instrumentation.ts index 1eec4a74ac..0b57cc6bc0 100644 --- a/packages/instrumentation-web-exception/src/instrumentation.ts +++ b/packages/instrumentation-web-exception/src/instrumentation.ts @@ -31,6 +31,8 @@ import { type AnyValueMap, } from '@opentelemetry/api-logs'; import { hrTime } from '@opentelemetry/core'; + +/** @knipignore */ import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; export interface GlobalErrorsInstrumentationConfig