diff --git a/.github/workflows/core_contrib_test_0.yml b/.github/workflows/core_contrib_test_0.yml index fa7f0d668b..37131badd2 100644 --- a/.github/workflows/core_contrib_test_0.yml +++ b/.github/workflows/core_contrib_test_0.yml @@ -1493,6 +1493,36 @@ jobs: - name: Run tests run: tox -e py39-test-instrumentation-logging -- -ra + py39-test-instrumentation-exceptions: + name: instrumentation-exceptions + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout contrib repo @ SHA - ${{ env.CONTRIB_REPO_SHA }} + uses: actions/checkout@v4 + with: + repository: open-telemetry/opentelemetry-python-contrib + ref: ${{ env.CONTRIB_REPO_SHA }} + + - name: Checkout core repo @ SHA - ${{ env.CORE_REPO_SHA }} + uses: actions/checkout@v4 + with: + repository: open-telemetry/opentelemetry-python + ref: ${{ env.CORE_REPO_SHA }} + path: opentelemetry-python + + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: "3.9" + architecture: "x64" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py39-test-instrumentation-exceptions -- -ra + py39-test-exporter-richconsole: name: exporter-richconsole runs-on: ubuntu-latest diff --git a/.github/workflows/lint_0.yml b/.github/workflows/lint_0.yml index cb7b726df9..2c9d4d4280 100644 --- a/.github/workflows/lint_0.yml +++ b/.github/workflows/lint_0.yml @@ -640,6 +640,25 @@ jobs: - name: Run tests run: tox -e lint-instrumentation-logging + lint-instrumentation-exceptions: + name: instrumentation-exceptions + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.14 + uses: actions/setup-python@v5 + with: + python-version: "3.14" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e lint-instrumentation-exceptions + lint-exporter-richconsole: name: exporter-richconsole runs-on: ubuntu-latest diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml index 3da7168646..ff16119df8 100644 --- a/.github/workflows/test_1.yml +++ b/.github/workflows/test_1.yml @@ -1552,6 +1552,120 @@ jobs: - name: Run tests run: tox -e pypy3-test-instrumentation-logging -- -ra + py39-test-instrumentation-exceptions_ubuntu-latest: + name: instrumentation-exceptions 3.9 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: "3.9" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py39-test-instrumentation-exceptions -- -ra + + py310-test-instrumentation-exceptions_ubuntu-latest: + name: instrumentation-exceptions 3.10 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py310-test-instrumentation-exceptions -- -ra + + py311-test-instrumentation-exceptions_ubuntu-latest: + name: instrumentation-exceptions 3.11 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py311-test-instrumentation-exceptions -- -ra + + py312-test-instrumentation-exceptions_ubuntu-latest: + name: instrumentation-exceptions 3.12 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py312-test-instrumentation-exceptions -- -ra + + py313-test-instrumentation-exceptions_ubuntu-latest: + name: instrumentation-exceptions 3.13 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py313-test-instrumentation-exceptions -- -ra + + pypy3-test-instrumentation-exceptions_ubuntu-latest: + name: instrumentation-exceptions pypy-3.9 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python pypy-3.9 + uses: actions/setup-python@v5 + with: + python-version: "pypy-3.9" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e pypy3-test-instrumentation-exceptions -- -ra + py39-test-exporter-richconsole_ubuntu-latest: name: exporter-richconsole 3.9 Ubuntu runs-on: ubuntu-latest @@ -4667,117 +4781,3 @@ jobs: - name: Run tests run: tox -e py314-test-instrumentation-sqlalchemy-2 -- -ra - - pypy3-test-instrumentation-sqlalchemy-0_ubuntu-latest: - name: instrumentation-sqlalchemy-0 pypy-3.9 Ubuntu - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python pypy-3.9 - uses: actions/setup-python@v5 - with: - python-version: "pypy-3.9" - - - name: Install tox - run: pip install tox-uv - - - name: Run tests - run: tox -e pypy3-test-instrumentation-sqlalchemy-0 -- -ra - - pypy3-test-instrumentation-sqlalchemy-1_ubuntu-latest: - name: instrumentation-sqlalchemy-1 pypy-3.9 Ubuntu - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python pypy-3.9 - uses: actions/setup-python@v5 - with: - python-version: "pypy-3.9" - - - name: Install tox - run: pip install tox-uv - - - name: Run tests - run: tox -e pypy3-test-instrumentation-sqlalchemy-1 -- -ra - - pypy3-test-instrumentation-sqlalchemy-2_ubuntu-latest: - name: instrumentation-sqlalchemy-2 pypy-3.9 Ubuntu - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python pypy-3.9 - uses: actions/setup-python@v5 - with: - python-version: "pypy-3.9" - - - name: Install tox - run: pip install tox-uv - - - name: Run tests - run: tox -e pypy3-test-instrumentation-sqlalchemy-2 -- -ra - - py39-test-instrumentation-redis_ubuntu-latest: - name: instrumentation-redis 3.9 Ubuntu - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: "3.9" - - - name: Install tox - run: pip install tox-uv - - - name: Run tests - run: tox -e py39-test-instrumentation-redis -- -ra - - py310-test-instrumentation-redis_ubuntu-latest: - name: instrumentation-redis 3.10 Ubuntu - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install tox - run: pip install tox-uv - - - name: Run tests - run: tox -e py310-test-instrumentation-redis -- -ra - - py311-test-instrumentation-redis_ubuntu-latest: - name: instrumentation-redis 3.11 Ubuntu - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Checkout repo @ SHA - ${{ github.sha }} - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Install tox - run: pip install tox-uv - - - name: Run tests - run: tox -e py311-test-instrumentation-redis -- -ra diff --git a/.github/workflows/test_2.yml b/.github/workflows/test_2.yml index bdc6cefdae..baa017b74a 100644 --- a/.github/workflows/test_2.yml +++ b/.github/workflows/test_2.yml @@ -32,6 +32,120 @@ env: jobs: + pypy3-test-instrumentation-sqlalchemy-0_ubuntu-latest: + name: instrumentation-sqlalchemy-0 pypy-3.9 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python pypy-3.9 + uses: actions/setup-python@v5 + with: + python-version: "pypy-3.9" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e pypy3-test-instrumentation-sqlalchemy-0 -- -ra + + pypy3-test-instrumentation-sqlalchemy-1_ubuntu-latest: + name: instrumentation-sqlalchemy-1 pypy-3.9 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python pypy-3.9 + uses: actions/setup-python@v5 + with: + python-version: "pypy-3.9" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e pypy3-test-instrumentation-sqlalchemy-1 -- -ra + + pypy3-test-instrumentation-sqlalchemy-2_ubuntu-latest: + name: instrumentation-sqlalchemy-2 pypy-3.9 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python pypy-3.9 + uses: actions/setup-python@v5 + with: + python-version: "pypy-3.9" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e pypy3-test-instrumentation-sqlalchemy-2 -- -ra + + py39-test-instrumentation-redis_ubuntu-latest: + name: instrumentation-redis 3.9 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: "3.9" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py39-test-instrumentation-redis -- -ra + + py310-test-instrumentation-redis_ubuntu-latest: + name: instrumentation-redis 3.10 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py310-test-instrumentation-redis -- -ra + + py311-test-instrumentation-redis_ubuntu-latest: + name: instrumentation-redis 3.11 Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py311-test-instrumentation-redis -- -ra + py312-test-instrumentation-redis_ubuntu-latest: name: instrumentation-redis 3.12 Ubuntu runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e01dbe8bc..4d98dbbac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#4141](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4141)) - `opentelemetry-instrumentation-pyramid`: pass request attributes at span creation ([#4139](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4139)) +- `opentelemetry-instrumentation-exceptions`: add instrumentation to emit LogRecords for uncaught exceptions and unhandled asyncio task exceptions +([#4211](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4211)) ### Fixed - `opentelemetry-instrumentation-mysql`: Refactor MySQL integration test mocks to use concrete DBAPI connection attributes, reducing noisy attribute type warnings. diff --git a/instrumentation/README.md b/instrumentation/README.md index 27008c0015..99becf571f 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -21,6 +21,7 @@ | [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | No | development | [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 2.0 | Yes | development | [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 6.0 | No | development +| [opentelemetry-instrumentation-exceptions](./opentelemetry-instrumentation-exceptions) | exceptions | No | development | [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon >= 1.4.1, < 5.0.0 | Yes | migration | [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.92 | Yes | migration | [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0 | Yes | migration diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/LICENSE b/instrumentation/opentelemetry-instrumentation-exceptions/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/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/instrumentation/opentelemetry-instrumentation-exceptions/README.rst b/instrumentation/opentelemetry-instrumentation-exceptions/README.rst new file mode 100644 index 0000000000..ed2f824a8a --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/README.rst @@ -0,0 +1,33 @@ +OpenTelemetry Exceptions Instrumentation +======================================== + +|pypi| + +.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-exceptions.svg + :target: https://pypi.org/project/opentelemetry-instrumentation-exceptions/ + +This library emits OpenTelemetry logs for uncaught exceptions and unhandled +asyncio task exceptions. + +Installation +------------ + +:: + + pip install opentelemetry-instrumentation-exceptions + +Usage +----- + +.. code:: python + + from opentelemetry.instrumentation.exceptions import ( + UnhandledExceptionInstrumentor, + ) + + UnhandledExceptionInstrumentor().instrument() + +References +---------- + +* `OpenTelemetry Project `_ diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/pyproject.toml b/instrumentation/opentelemetry-instrumentation-exceptions/pyproject.toml new file mode 100644 index 0000000000..20aff5ebed --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/pyproject.toml @@ -0,0 +1,52 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "opentelemetry-instrumentation-exceptions" +dynamic = ["version"] +description = "OpenTelemetry unhandled exceptions instrumentation" +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.9" +authors = [ + { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + "opentelemetry-api ~= 1.12", + "opentelemetry-instrumentation == 0.61b0.dev", +] + +[project.optional-dependencies] +instruments = [] + +[project.entry-points.opentelemetry_instrumentor] +exceptions = "opentelemetry.instrumentation.exceptions:UnhandledExceptionInstrumentor" + +[project.urls] +Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-exceptions" +Repository = "https://github.com/open-telemetry/opentelemetry-python-contrib" + +[tool.hatch.version] +path = "src/opentelemetry/instrumentation/exceptions/version.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/src", + "/tests", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/opentelemetry"] diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/__init__.py b/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/__init__.py new file mode 100644 index 0000000000..f541527766 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/__init__.py @@ -0,0 +1,254 @@ +# 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. +""" +Emit OpenTelemetry log records for unhandled exceptions. + +Usage +----- + +.. code-block:: python + + from opentelemetry.instrumentation.exceptions import ( + UnhandledExceptionInstrumentor, + ) + + UnhandledExceptionInstrumentor().instrument() +""" + +from __future__ import annotations + +import asyncio +import sys +import threading +import traceback +from typing import Any, Callable, Collection + +from opentelemetry._logs import LogRecord, get_logger +from opentelemetry.context import get_current +from opentelemetry.instrumentation.exceptions.package import _instruments +from opentelemetry.instrumentation.exceptions.version import __version__ +from opentelemetry.instrumentation.instrumentor import BaseInstrumentor +from opentelemetry.semconv.attributes import exception_attributes +from opentelemetry.semconv.schemas import Schemas + +try: # pragma: no cover - optional API for older SDKs + from opentelemetry._logs import SeverityNumber +except ImportError: # pragma: no cover - older SDKs don't expose this + SeverityNumber = None + + +def _format_stacktrace( + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: Any, +) -> str | None: + if exc_type is None and exc is not None: + exc_type = type(exc) + if tb is None and exc is not None: + tb = exc.__traceback__ + if exc_type is None: + return None + return "".join(traceback.format_exception(exc_type, exc, tb)) + + +def _exception_attributes( + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: Any, +) -> dict[str, str]: + attributes: dict[str, str] = {} + if exc_type is None and exc is not None: + exc_type = type(exc) + if exc_type is not None: + attributes[exception_attributes.EXCEPTION_TYPE] = exc_type.__name__ + if exc is not None: + attributes[exception_attributes.EXCEPTION_MESSAGE] = str(exc) + stacktrace = _format_stacktrace(exc_type, exc, tb) + if stacktrace: + attributes[exception_attributes.EXCEPTION_STACKTRACE] = stacktrace + return attributes + + +def _severity_number(severity_text: str) -> Any: + if SeverityNumber is None: + return None + if severity_text == "FATAL": + return SeverityNumber.FATAL + if severity_text == "ERROR": + return SeverityNumber.ERROR + return None + + +class _ExceptionLogger: + def __init__(self, logger_provider=None): + self._logger = get_logger( + __name__, + __version__, + logger_provider, + schema_url=Schemas.V1_37_0.value, + ) + + def emit( + self, + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: Any, + severity_text: str, + ) -> None: + attributes = _exception_attributes(exc_type, exc, tb) + log_record = LogRecord( + attributes=attributes or None, + body=str(exc) if exc is not None else None, + severity_text=severity_text, + severity_number=_severity_number(severity_text), + context=get_current(), + ) + self._logger.emit(log_record) + + +class UnhandledExceptionInstrumentor(BaseInstrumentor): + """Emit logs for uncaught exceptions and unhandled asyncio exceptions.""" + + def __init__(self, logger_provider=None): + super().__init__() + self._logger_provider = logger_provider + self._exception_logger: _ExceptionLogger | None = None + self._original_sys_excepthook: Callable[..., Any] | None = None + self._original_threading_excepthook: Callable[..., Any] | None = None + self._original_asyncio_call_exception_handler: ( + Callable[..., Any] | None + ) = None + self._sys_excepthook: Callable[..., Any] | None = None + self._threading_excepthook: Callable[..., Any] | None = None + self._asyncio_call_exception_handler: Callable[..., Any] | None = None + + def instrumentation_dependencies(self) -> Collection[str]: + return _instruments + + def _instrument(self, **kwargs: Any): + logger_provider = kwargs.get("logger_provider", self._logger_provider) + self._exception_logger = _ExceptionLogger(logger_provider) + self._install_sys_hook() + self._install_threading_hook() + self._install_asyncio_hook() + + def _uninstrument(self, **kwargs: Any): + self._restore_sys_hook() + self._restore_threading_hook() + self._restore_asyncio_hook() + self._exception_logger = None + + def _install_sys_hook(self) -> None: + if self._original_sys_excepthook is not None: + return + + self._original_sys_excepthook = sys.excepthook + + def _handle_sys_exc(exc_type, exc, tb): + if self._exception_logger is not None: + try: + self._exception_logger.emit(exc_type, exc, tb, "FATAL") + except Exception: # pragma: no cover - defensive # pylint: disable=broad-exception-caught + pass + return self._original_sys_excepthook(exc_type, exc, tb) + + self._sys_excepthook = _handle_sys_exc + sys.excepthook = _handle_sys_exc + + def _restore_sys_hook(self) -> None: + if ( + self._original_sys_excepthook is not None + and sys.excepthook is self._sys_excepthook + ): + sys.excepthook = self._original_sys_excepthook + self._original_sys_excepthook = None + self._sys_excepthook = None + + def _install_threading_hook(self) -> None: + if not hasattr(threading, "excepthook"): + return + if self._original_threading_excepthook is not None: + return + + self._original_threading_excepthook = threading.excepthook + + def _handle_threading_exc(args): + if self._exception_logger is not None: + try: + self._exception_logger.emit( + args.exc_type, + args.exc_value, + args.exc_traceback, + "ERROR", + ) + except Exception: # pragma: no cover - defensive # pylint: disable=broad-exception-caught + pass + return self._original_threading_excepthook(args) + + self._threading_excepthook = _handle_threading_exc + threading.excepthook = _handle_threading_exc + + def _restore_threading_hook(self) -> None: + if not hasattr(threading, "excepthook"): + return + if ( + self._original_threading_excepthook is not None + and threading.excepthook is self._threading_excepthook + ): + threading.excepthook = self._original_threading_excepthook + self._original_threading_excepthook = None + self._threading_excepthook = None + + def _install_asyncio_hook(self) -> None: + if self._original_asyncio_call_exception_handler is not None: + return + base_loop = getattr(asyncio, "BaseEventLoop", None) + if base_loop is None: + return + + self._original_asyncio_call_exception_handler = ( + base_loop.call_exception_handler + ) + + def _call_exception_handler(loop, context): + exc = context.get("exception") if context else None + if exc is not None and self._exception_logger is not None: + try: + self._exception_logger.emit( + type(exc), exc, exc.__traceback__, "ERROR" + ) + except Exception: # pragma: no cover - defensive # pylint: disable=broad-exception-caught + pass + return self._original_asyncio_call_exception_handler(loop, context) + + self._asyncio_call_exception_handler = _call_exception_handler + base_loop.call_exception_handler = _call_exception_handler + + def _restore_asyncio_hook(self) -> None: + base_loop = getattr(asyncio, "BaseEventLoop", None) + if base_loop is None: + return + if ( + self._original_asyncio_call_exception_handler is not None + and base_loop.call_exception_handler + is self._asyncio_call_exception_handler + ): + base_loop.call_exception_handler = ( + self._original_asyncio_call_exception_handler + ) + self._original_asyncio_call_exception_handler = None + self._asyncio_call_exception_handler = None + + +__all__ = ["UnhandledExceptionInstrumentor"] diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/package.py b/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/package.py new file mode 100644 index 0000000000..7a66a17a93 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/package.py @@ -0,0 +1,16 @@ +# 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. + + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/version.py b/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/version.py new file mode 100644 index 0000000000..076fd05e70 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/src/opentelemetry/instrumentation/exceptions/version.py @@ -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 +# +# 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. + +__version__ = "0.61b0.dev" + +_instruments = tuple() diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-exceptions/test-requirements.txt new file mode 100644 index 0000000000..98daac062e --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/test-requirements.txt @@ -0,0 +1,13 @@ +asgiref==3.8.1 +Deprecated==1.2.14 +iniconfig==2.0.0 +packaging==24.0 +pluggy==1.5.0 +py-cpuinfo==9.0.0 +pytest==7.4.4 +tomli==2.0.1 +typing_extensions==4.12.2 +wrapt==1.16.0 +zipp==3.19.2 +-e opentelemetry-instrumentation +-e instrumentation/opentelemetry-instrumentation-exceptions diff --git a/instrumentation/opentelemetry-instrumentation-exceptions/tests/test_exceptions_instrumentation.py b/instrumentation/opentelemetry-instrumentation-exceptions/tests/test_exceptions_instrumentation.py new file mode 100644 index 0000000000..407a4ab0f6 --- /dev/null +++ b/instrumentation/opentelemetry-instrumentation-exceptions/tests/test_exceptions_instrumentation.py @@ -0,0 +1,212 @@ +# 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 asyncio +import sys +import threading + +import pytest + +import opentelemetry._logs._internal +from opentelemetry._logs import get_logger_provider, set_logger_provider +from opentelemetry.sdk._logs import LoggerProvider + +# Backward compatibility for InMemoryLogExporter -> InMemoryLogRecordExporter +try: + from opentelemetry.sdk._logs.export import ( # pylint: disable=no-name-in-module + InMemoryLogRecordExporter, + SimpleLogRecordProcessor, + ) +except ImportError: + from opentelemetry.sdk._logs.export import ( # type: ignore + InMemoryLogExporter as InMemoryLogRecordExporter, + ) + from opentelemetry.sdk._logs.export import SimpleLogRecordProcessor +from opentelemetry.instrumentation.exceptions import ( + UnhandledExceptionInstrumentor, + _exception_attributes, + _format_stacktrace, + _severity_number, +) +from opentelemetry.semconv.attributes import exception_attributes +from opentelemetry.util._once import Once + +# pylint: disable=redefined-outer-name + + +@pytest.fixture +def log_exporter(): + snapshot = get_logger_provider() + opentelemetry._logs._internal._LOGGER_PROVIDER_SET_ONCE = Once() + provider = LoggerProvider() + exporter = InMemoryLogRecordExporter() + provider.add_log_record_processor(SimpleLogRecordProcessor(exporter)) + set_logger_provider(provider) + try: + yield exporter + finally: + opentelemetry._logs._internal._LOGGER_PROVIDER_SET_ONCE = Once() + set_logger_provider(snapshot) + + +@pytest.fixture +def instrumentor(): + inst = UnhandledExceptionInstrumentor() + try: + yield inst + finally: + inst.uninstrument() + + +def _raise_value_error(): + try: + raise ValueError("boom") + except ValueError as exc: + return exc, exc.__traceback__ + + +def _get_single_log(log_exporter): + logs = log_exporter.get_finished_logs() + assert len(logs) == 1 + return logs[0].log_record + + +def test_sys_excepthook_emits_log(log_exporter, monkeypatch, instrumentor): + called = {"value": False} + + def stub_excepthook(exc_type, exc, tb): + called["value"] = True + + monkeypatch.setattr("sys.excepthook", stub_excepthook) + instrumentor.instrument() + + exc, tb = _raise_value_error() + sys.excepthook(type(exc), exc, tb) + + log_record = _get_single_log(log_exporter) + assert log_record.severity_text == "FATAL" + attrs = log_record.attributes + assert attrs[exception_attributes.EXCEPTION_TYPE] == "ValueError" + assert attrs[exception_attributes.EXCEPTION_MESSAGE] == "boom" + assert ( + "ValueError: boom" in attrs[exception_attributes.EXCEPTION_STACKTRACE] + ) + assert called["value"] is True + + +def test_threading_excepthook_emits_log( + log_exporter, monkeypatch, instrumentor +): + called = {"value": False} + + def stub_threading_excepthook(args): + called["value"] = True + + monkeypatch.setattr("threading.excepthook", stub_threading_excepthook) + instrumentor.instrument() + + exc, tb = _raise_value_error() + args = threading.ExceptHookArgs( + (type(exc), exc, tb, threading.current_thread()) + ) + threading.excepthook(args) + + log_record = _get_single_log(log_exporter) + assert log_record.severity_text == "ERROR" + attrs = log_record.attributes + assert attrs[exception_attributes.EXCEPTION_TYPE] == "ValueError" + assert attrs[exception_attributes.EXCEPTION_MESSAGE] == "boom" + assert ( + "ValueError: boom" in attrs[exception_attributes.EXCEPTION_STACKTRACE] + ) + assert called["value"] is True + + +def test_asyncio_unhandled_exception_emits_log(log_exporter, instrumentor): + instrumentor.instrument() + + loop = asyncio.new_event_loop() + loop.set_exception_handler(lambda _loop, _context: None) + try: + exc, _ = _raise_value_error() + loop.call_exception_handler({"exception": exc, "message": "boom"}) + finally: + loop.close() + + log_record = _get_single_log(log_exporter) + assert log_record.severity_text == "ERROR" + attrs = log_record.attributes + assert attrs[exception_attributes.EXCEPTION_TYPE] == "ValueError" + assert attrs[exception_attributes.EXCEPTION_MESSAGE] == "boom" + assert ( + "ValueError: boom" in attrs[exception_attributes.EXCEPTION_STACKTRACE] + ) + + +def test_uninstrument_restores_hooks(monkeypatch, log_exporter): + instrumentor = UnhandledExceptionInstrumentor() + + original_sys = object() + original_threading = object() + + monkeypatch.setattr("sys.excepthook", original_sys) + monkeypatch.setattr("threading.excepthook", original_threading) + + instrumentor.instrument() + instrumentor.uninstrument() + + assert sys.excepthook is original_sys + assert threading.excepthook is original_threading + + +def test_helper_functions_cover_branches(monkeypatch): + exc, tb = _raise_value_error() + + # _format_stacktrace covers exc_type/tb inference and None return + assert _format_stacktrace(None, exc, None) is not None + assert _format_stacktrace(None, None, None) is None + + # _exception_attributes covers exc_type inference + attrs = _exception_attributes(None, exc, tb) + assert attrs[exception_attributes.EXCEPTION_TYPE] == "ValueError" + + # _severity_number covers non-standard severity and None SeverityNumber + assert _severity_number("INFO") is None + monkeypatch.setattr( + "opentelemetry.instrumentation.exceptions.SeverityNumber", + None, + ) + assert _severity_number("ERROR") is None + + +def test_internal_hooks_short_circuit(monkeypatch, log_exporter): + instrumentor = UnhandledExceptionInstrumentor() + instrumentor.instrument() + + # Already installed paths + instrumentor._install_sys_hook() + instrumentor._install_threading_hook() + instrumentor._install_asyncio_hook() + + instrumentor.uninstrument() + + # Missing threading.excepthook path + monkeypatch.delattr(threading, "excepthook", raising=False) + instrumentor._install_threading_hook() + instrumentor._restore_threading_hook() + + # Missing asyncio.BaseEventLoop path + monkeypatch.setattr(asyncio, "BaseEventLoop", None) + instrumentor._install_asyncio_hook() + instrumentor._restore_asyncio_hook() diff --git a/opentelemetry-contrib-instrumentations/pyproject.toml b/opentelemetry-contrib-instrumentations/pyproject.toml index 13c1ccbf1c..83b608f9f4 100644 --- a/opentelemetry-contrib-instrumentations/pyproject.toml +++ b/opentelemetry-contrib-instrumentations/pyproject.toml @@ -50,6 +50,7 @@ dependencies = [ "opentelemetry-instrumentation-dbapi==0.61b0.dev", "opentelemetry-instrumentation-django==0.61b0.dev", "opentelemetry-instrumentation-elasticsearch==0.61b0.dev", + "opentelemetry-instrumentation-exceptions==0.61b0.dev", "opentelemetry-instrumentation-falcon==0.61b0.dev", "opentelemetry-instrumentation-fastapi==0.61b0.dev", "opentelemetry-instrumentation-flask==0.61b0.dev", diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index 47ed388c32..078d849872 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -216,6 +216,7 @@ default_instrumentations = [ "opentelemetry-instrumentation-asyncio==0.61b0.dev", "opentelemetry-instrumentation-dbapi==0.61b0.dev", + "opentelemetry-instrumentation-exceptions==0.61b0.dev", "opentelemetry-instrumentation-logging==0.61b0.dev", "opentelemetry-instrumentation-sqlite3==0.61b0.dev", "opentelemetry-instrumentation-threading==0.61b0.dev", diff --git a/pyproject.toml b/pyproject.toml index 99ba8d2e32..3f13a0142a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dependencies = [ "opentelemetry-instrumentation-kafka-python[instruments]", "opentelemetry-instrumentation-kafka-python[instruments-any]", "opentelemetry-instrumentation-logging", + "opentelemetry-instrumentation-exceptions", "opentelemetry-instrumentation-mysql[instruments]", "opentelemetry-instrumentation-mysqlclient[instruments]", "opentelemetry-instrumentation-pika[instruments]", @@ -111,6 +112,7 @@ opentelemetry-instrumentation-httpx = { workspace = true } opentelemetry-instrumentation-jinja2 = { workspace = true } opentelemetry-instrumentation-kafka-python = { workspace = true } opentelemetry-instrumentation-logging = { workspace = true } +opentelemetry-instrumentation-exceptions = { workspace = true } opentelemetry-instrumentation-mysql = { workspace = true } opentelemetry-instrumentation-mysqlclient = { workspace = true } opentelemetry-instrumentation-pika = { workspace = true } diff --git a/tox.ini b/tox.ini index d1989a834b..76e8479e10 100644 --- a/tox.ini +++ b/tox.ini @@ -212,6 +212,11 @@ envlist = pypy3-test-instrumentation-logging lint-instrumentation-logging + ; opentelemetry-instrumentation-exceptions + py3{9,10,11,12,13}-test-instrumentation-exceptions + pypy3-test-instrumentation-exceptions + lint-instrumentation-exceptions + ; opentelemetry-exporter-richconsole py3{9,10,11,12,13,14}-test-exporter-richconsole pypy3-test-exporter-richconsole @@ -686,6 +691,9 @@ deps = logging: {[testenv]test_deps} logging: -r {toxinidir}/instrumentation/opentelemetry-instrumentation-logging/test-requirements.txt + exceptions: {[testenv]test_deps} + exceptions: -r {toxinidir}/instrumentation/opentelemetry-instrumentation-exceptions/test-requirements.txt + aiohttp-client: {[testenv]test_deps} aiohttp-client: -r {toxinidir}/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt @@ -876,6 +884,8 @@ commands = test-instrumentation-logging: pytest {toxinidir}/instrumentation/opentelemetry-instrumentation-logging/tests {posargs} lint-instrumentation-logging: sh -c "cd instrumentation && pylint --rcfile ../.pylintrc opentelemetry-instrumentation-logging" + test-instrumentation-exceptions: pytest {toxinidir}/instrumentation/opentelemetry-instrumentation-exceptions/tests {posargs} + lint-instrumentation-exceptions: sh -c "cd instrumentation && pylint --rcfile ../.pylintrc opentelemetry-instrumentation-exceptions" test-instrumentation-mysql: pytest {toxinidir}/instrumentation/opentelemetry-instrumentation-mysql/tests {posargs} lint-instrumentation-mysql: sh -c "cd instrumentation && pylint --rcfile ../.pylintrc opentelemetry-instrumentation-mysql" diff --git a/uv.lock b/uv.lock index d75bd7e73c..2df81f0c2b 100644 --- a/uv.lock +++ b/uv.lock @@ -37,6 +37,7 @@ members = [ "opentelemetry-instrumentation-dbapi", "opentelemetry-instrumentation-django", "opentelemetry-instrumentation-elasticsearch", + "opentelemetry-instrumentation-exceptions", "opentelemetry-instrumentation-falcon", "opentelemetry-instrumentation-fastapi", "opentelemetry-instrumentation-flask", @@ -3252,6 +3253,21 @@ requires-dist = [ ] provides-extras = ["instruments"] +[[package]] +name = "opentelemetry-instrumentation-exceptions" +source = { editable = "instrumentation/opentelemetry-instrumentation-exceptions" } +dependencies = [ + { name = "opentelemetry-api" }, + { name = "opentelemetry-instrumentation" }, +] + +[package.metadata] +requires-dist = [ + { name = "opentelemetry-api", git = "https://github.com/open-telemetry/opentelemetry-python?subdirectory=opentelemetry-api&branch=main" }, + { name = "opentelemetry-instrumentation", editable = "opentelemetry-instrumentation" }, +] +provides-extras = ["instruments"] + [[package]] name = "opentelemetry-instrumentation-falcon" source = { editable = "instrumentation/opentelemetry-instrumentation-falcon" } @@ -4186,6 +4202,7 @@ dependencies = [ { name = "opentelemetry-instrumentation-dbapi" }, { name = "opentelemetry-instrumentation-django", extra = ["instruments"] }, { name = "opentelemetry-instrumentation-elasticsearch", extra = ["instruments"] }, + { name = "opentelemetry-instrumentation-exceptions" }, { name = "opentelemetry-instrumentation-falcon", extra = ["instruments"] }, { name = "opentelemetry-instrumentation-fastapi", extra = ["instruments"] }, { name = "opentelemetry-instrumentation-flask", extra = ["instruments"] }, @@ -4258,6 +4275,7 @@ requires-dist = [ { name = "opentelemetry-instrumentation-dbapi", editable = "instrumentation/opentelemetry-instrumentation-dbapi" }, { name = "opentelemetry-instrumentation-django", extras = ["instruments"], editable = "instrumentation/opentelemetry-instrumentation-django" }, { name = "opentelemetry-instrumentation-elasticsearch", extras = ["instruments"], editable = "instrumentation/opentelemetry-instrumentation-elasticsearch" }, + { name = "opentelemetry-instrumentation-exceptions", editable = "instrumentation/opentelemetry-instrumentation-exceptions" }, { name = "opentelemetry-instrumentation-falcon", extras = ["instruments"], editable = "instrumentation/opentelemetry-instrumentation-falcon" }, { name = "opentelemetry-instrumentation-fastapi", extras = ["instruments"], editable = "instrumentation/opentelemetry-instrumentation-fastapi" }, { name = "opentelemetry-instrumentation-flask", extras = ["instruments"], editable = "instrumentation/opentelemetry-instrumentation-flask" },