From 5cb779ff231486ad813c6c5121a1785df1938cb0 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Mon, 15 Jun 2026 22:19:58 -0400 Subject: [PATCH 1/8] opentelemetry-exporter-otlp-common: add shared package for common OTLP utilities --- .github/workflows/lint.yml | 19 + .github/workflows/test.yml | 480 ++++++++++++++++++ eachdist.ini | 1 + .../LICENSE | 201 ++++++++ .../README.rst | 53 ++ .../pyproject.toml | 51 ++ .../exporter/otlp/common/__init__.py | 2 + .../exporter/otlp/common/_aggregation.py | 123 +++++ .../exporter/otlp/common/_http.py | 236 +++++++++ .../exporter/otlp/common/py.typed | 0 .../exporter/otlp/common/version/__init__.py | 4 + .../test-requirements.in | 10 + .../test-requirements.latest.txt | 69 +++ .../test-requirements.oldest.txt | 69 +++ .../tests/__init__.py | 2 + .../tests/test_aggregation.py | 151 ++++++ .../tests/test_http_client.py | 462 +++++++++++++++++ tox.ini | 10 + uv.lock | 160 +++--- 19 files changed, 2033 insertions(+), 70 deletions(-) create mode 100644 exporter/opentelemetry-exporter-otlp-common/LICENSE create mode 100644 exporter/opentelemetry-exporter-otlp-common/README.rst create mode 100644 exporter/opentelemetry-exporter-otlp-common/pyproject.toml create mode 100644 exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/__init__.py create mode 100644 exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py create mode 100644 exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py create mode 100644 exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/py.typed create mode 100644 exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py create mode 100644 exporter/opentelemetry-exporter-otlp-common/test-requirements.in create mode 100644 exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt create mode 100644 exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt create mode 100644 exporter/opentelemetry-exporter-otlp-common/tests/__init__.py create mode 100644 exporter/opentelemetry-exporter-otlp-common/tests/test_aggregation.py create mode 100644 exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 27033640dc1..457aea69582 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -214,6 +214,25 @@ jobs: - name: Run tests run: tox -e lint-opentelemetry-exporter-http-transport + lint-opentelemetry-exporter-otlp-common-latest: + name: opentelemetry-exporter-otlp-common-latest + 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-opentelemetry-exporter-otlp-common-latest + lint-opentelemetry-exporter-opencensus: name: opentelemetry-exporter-opencensus runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d562b9d8745..a5dbadd4c00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1642,6 +1642,234 @@ jobs: - name: Run tests run: tox -e py314t-test-opentelemetry-exporter-http-transport-latest -- -ra + py310-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-oldest 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py310-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-latest 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py311-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-oldest 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py311-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-latest 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py312-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-oldest 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py312-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-latest 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py313-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-oldest 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py313-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-latest 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py314-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.14 Ubuntu + 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 py314-test-opentelemetry-exporter-otlp-common-oldest -- -ra + + py314-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-latest 3.14 Ubuntu + 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 py314-test-opentelemetry-exporter-otlp-common-latest -- -ra + + py314t-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.14t Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.14t + uses: actions/setup-python@v5 + with: + python-version: "3.14t" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py314t-test-opentelemetry-exporter-otlp-common-oldest -- -ra + + py314t-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: + name: opentelemetry-exporter-otlp-common-latest 3.14t Ubuntu + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.14t + uses: actions/setup-python@v5 + with: + python-version: "3.14t" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py314t-test-opentelemetry-exporter-otlp-common-latest -- -ra + py310-test-opentelemetry-exporter-opencensus_ubuntu-latest: name: opentelemetry-exporter-opencensus 3.10 Ubuntu runs-on: ubuntu-latest @@ -5280,6 +5508,258 @@ jobs: - name: Run tests run: tox -e py314t-test-opentelemetry-exporter-http-transport-latest -- -ra + py310-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.10 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py310-test-opentelemetry-exporter-otlp-common-latest_windows-latest: + name: opentelemetry-exporter-otlp-common-latest 3.10 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py311-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.11 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py311-test-opentelemetry-exporter-otlp-common-latest_windows-latest: + name: opentelemetry-exporter-otlp-common-latest 3.11 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py312-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.12 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py312-test-opentelemetry-exporter-otlp-common-latest_windows-latest: + name: opentelemetry-exporter-otlp-common-latest 3.12 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py313-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.13 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-oldest -- -ra + + py313-test-opentelemetry-exporter-otlp-common-latest_windows-latest: + name: opentelemetry-exporter-otlp-common-latest 3.13 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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-opentelemetry-exporter-otlp-common-latest -- -ra + + py314-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.14 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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 py314-test-opentelemetry-exporter-otlp-common-oldest -- -ra + + py314-test-opentelemetry-exporter-otlp-common-latest_windows-latest: + name: opentelemetry-exporter-otlp-common-latest 3.14 Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - 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 py314-test-opentelemetry-exporter-otlp-common-latest -- -ra + + py314t-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: + name: opentelemetry-exporter-otlp-common-oldest 3.14t Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.14t + uses: actions/setup-python@v5 + with: + python-version: "3.14t" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py314t-test-opentelemetry-exporter-otlp-common-oldest -- -ra + + py314t-test-opentelemetry-exporter-otlp-common-latest_windows-latest: + name: opentelemetry-exporter-otlp-common-latest 3.14t Windows + runs-on: windows-latest + timeout-minutes: 30 + steps: + - name: Configure git to support long filenames + run: git config --system core.longpaths true + - name: Checkout repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Set up Python 3.14t + uses: actions/setup-python@v5 + with: + python-version: "3.14t" + + - name: Install tox + run: pip install tox-uv + + - name: Run tests + run: tox -e py314t-test-opentelemetry-exporter-otlp-common-latest -- -ra + py310-test-opentelemetry-exporter-opencensus_windows-latest: name: opentelemetry-exporter-opencensus 3.10 Windows runs-on: windows-latest diff --git a/eachdist.ini b/eachdist.ini index 1afbf3da92f..d56d8912e2a 100644 --- a/eachdist.ini +++ b/eachdist.ini @@ -37,6 +37,7 @@ packages= opentelemetry-exporter-prometheus opentelemetry-exporter-otlp-json-common opentelemetry-exporter-otlp-json-file + opentelemetry-exporter-otlp-common opentelemetry-distro opentelemetry-proto-json opentelemetry-semantic-conventions diff --git a/exporter/opentelemetry-exporter-otlp-common/LICENSE b/exporter/opentelemetry-exporter-otlp-common/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/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/exporter/opentelemetry-exporter-otlp-common/README.rst b/exporter/opentelemetry-exporter-otlp-common/README.rst new file mode 100644 index 00000000000..5db31d7a229 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/README.rst @@ -0,0 +1,53 @@ +OpenTelemetry OTLP HTTP Common +=============================== + +|pypi| + +.. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp-common.svg + :target: https://pypi.org/project/opentelemetry-exporter-otlp-common/ + +OpenTelemetry OTLP HTTP export utilities. + +This package is intended to be used by OpenTelemetry signal exporters (traces, metrics, +logs) that send telemetry over OTLP/HTTP. Currently, all functionality in this package +is marked as internal and is not intended for use directly by application developers. + +Installation +------------ + +:: + + pip install opentelemetry-exporter-otlp-common + +Usage +----- + +``OTLPHTTPClient`` wraps a transport and handles retry and compression. Pass it a +transport and an endpoint, then call ``export()`` with a serialized OTLP payload:: + + from opentelemetry.exporter.http.transport._requests import RequestsHTTPTransport + from opentelemetry.exporter.otlp.http.common._otlp_client import ( + Compression, + OTLPHTTPClient, + ) + + transport = RequestsHTTPTransport() + client = OTLPHTTPClient( + transport=transport, + endpoint="http://localhost:4318/v1/traces", + kind="spans", + compression=Compression.GZIP, + ) + + result = client.export(serialized_bytes) + if not result.success: + print(f"Export failed: {result.status_code} {result.reason}") + + client.close() + +References +---------- + +* `OpenTelemetry `_ +* `OTLP Specification `_ +* `opentelemetry-exporter-http-transport `_ diff --git a/exporter/opentelemetry-exporter-otlp-common/pyproject.toml b/exporter/opentelemetry-exporter-otlp-common/pyproject.toml new file mode 100644 index 00000000000..e849871c234 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "opentelemetry-exporter-otlp-common" +dynamic = ["version"] +description = "OpenTelemetry OTLP HTTP export utilities" +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.10" +authors = [ + { name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Framework :: OpenTelemetry", + "Framework :: OpenTelemetry :: Exporters", + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +dependencies = [ + "opentelemetry-sdk ~= 1.43.0.dev", +] + +[project.optional-dependencies] +http = [ + "opentelemetry-exporter-http-transport == 0.64b0.dev", +] + +[project.urls] +Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/exporter/opentelemetry-exporter-otlp-common" +Repository = "https://github.com/open-telemetry/opentelemetry-python" + +[tool.hatch.version] +path = "src/opentelemetry/exporter/otlp/common/version/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/src", + "/tests", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/opentelemetry"] diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/__init__.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/__init__.py new file mode 100644 index 00000000000..e57cf4aba95 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/__init__.py @@ -0,0 +1,2 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py new file mode 100644 index 00000000000..bf60f05d848 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py @@ -0,0 +1,123 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import annotations + +import logging +import os + +from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION, + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, +) +from opentelemetry.sdk.metrics import ( + Counter, + Histogram, + ObservableCounter, + ObservableGauge, + ObservableUpDownCounter, + UpDownCounter, +) +from opentelemetry.sdk.metrics.export import AggregationTemporality +from opentelemetry.sdk.metrics.view import ( + Aggregation, + ExplicitBucketHistogramAggregation, + ExponentialBucketHistogramAggregation, +) + +_logger = logging.getLogger(__name__) + + +def _get_temporality( + preferred_temporality: dict[type, AggregationTemporality] | None, +) -> dict[type, AggregationTemporality]: + temporality_preference = ( + os.environ.get( + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, + "CUMULATIVE", + ) + .upper() + .strip() + ) + + match temporality_preference: + case "DELTA": + instrument_class_temporality: dict[ + type, AggregationTemporality + ] = { + Counter: AggregationTemporality.DELTA, + UpDownCounter: AggregationTemporality.CUMULATIVE, + Histogram: AggregationTemporality.DELTA, + ObservableCounter: AggregationTemporality.DELTA, + ObservableUpDownCounter: AggregationTemporality.CUMULATIVE, + ObservableGauge: AggregationTemporality.CUMULATIVE, + } + case "LOWMEMORY": + instrument_class_temporality: dict[ + type, AggregationTemporality + ] = { + Counter: AggregationTemporality.DELTA, + UpDownCounter: AggregationTemporality.CUMULATIVE, + Histogram: AggregationTemporality.DELTA, + ObservableCounter: AggregationTemporality.CUMULATIVE, + ObservableUpDownCounter: AggregationTemporality.CUMULATIVE, + ObservableGauge: AggregationTemporality.CUMULATIVE, + } + case _: + if temporality_preference != "CUMULATIVE": + _logger.warning( + "Unrecognized OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE" + " value found: " + "%s, " + "using CUMULATIVE", + temporality_preference, + ) + instrument_class_temporality: dict[ + type, AggregationTemporality + ] = { + Counter: AggregationTemporality.CUMULATIVE, + UpDownCounter: AggregationTemporality.CUMULATIVE, + Histogram: AggregationTemporality.CUMULATIVE, + ObservableCounter: AggregationTemporality.CUMULATIVE, + ObservableUpDownCounter: AggregationTemporality.CUMULATIVE, + ObservableGauge: AggregationTemporality.CUMULATIVE, + } + + instrument_class_temporality.update(preferred_temporality or {}) + return instrument_class_temporality + + +def _get_aggregation( + preferred_aggregation: dict[type, Aggregation] | None, +) -> dict[type, Aggregation]: + default_histogram_aggregation = ( + os.environ.get( + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION, + "explicit_bucket_histogram", + ) + .upper() + .strip() + ) + + match default_histogram_aggregation: + case "BASE2_EXPONENTIAL_BUCKET_HISTOGRAM": + instrument_class_aggregation: dict[type, Aggregation] = { + Histogram: ExponentialBucketHistogramAggregation(), + } + case _: + if default_histogram_aggregation != "EXPLICIT_BUCKET_HISTOGRAM": + _logger.warning( + ( + "Invalid value for %s: %s, using explicit bucket " + "histogram aggregation" + ), + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION, + default_histogram_aggregation, + ) + + instrument_class_aggregation: dict[type, Aggregation] = { + Histogram: ExplicitBucketHistogramAggregation(), + } + + instrument_class_aggregation.update(preferred_aggregation or {}) + return instrument_class_aggregation diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py new file mode 100644 index 00000000000..fa8303ae56e --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py @@ -0,0 +1,236 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import annotations + +import enum +import gzip +import logging +import random +import threading +import time +import zlib +from collections.abc import Mapping +from dataclasses import dataclass +from http import HTTPStatus +from io import BytesIO +from typing import TYPE_CHECKING, Final, Literal + +if TYPE_CHECKING: + # pylint: disable-next=import-error + from opentelemetry.exporter.http.transport._base import ( + BaseHTTPResult, + BaseHTTPTransport, + ) + +_logger = logging.getLogger(__name__) + +_MAX_RETRIES: Final[int] = 6 +_DEFAULT_TIMEOUT: Final[float] = 10.0 +_DEFAULT_JITTER: Final[float] = 0.2 + + +_RETRYABLE_STATUS_CODES: Final[frozenset[int]] = frozenset( + { + HTTPStatus.TOO_MANY_REQUESTS.value, + HTTPStatus.BAD_GATEWAY.value, + HTTPStatus.SERVICE_UNAVAILABLE.value, + HTTPStatus.GATEWAY_TIMEOUT.value, + } +) + + +def _is_retryable(status_code: int | None) -> bool: + return status_code in _RETRYABLE_STATUS_CODES + + +def _extract_retry_after(result: BaseHTTPResult) -> float | None: + try: + value = result.headers().get("retry-after") + if value is not None: + return float(value) + # pylint: disable-next=broad-exception-caught + except Exception: + pass + return None + + +class Compression(enum.Enum): + NONE = "none" + DEFLATE = "deflate" + GZIP = "gzip" + + @staticmethod + def from_str(value: str) -> Compression: + match value.strip().lower(): + case "none": + return Compression.NONE + case "deflate": + return Compression.DEFLATE + case "gzip": + return Compression.GZIP + case _: + raise ValueError( + f"Invalid compression type: {value!r}. " + "Expected one of: 'none', 'deflate', 'gzip'." + ) + + +@dataclass(slots=True, frozen=True) +class ExportResult: + """Outcome of an OTLP export attempt, including retry exhaustion.""" + + success: bool + status_code: int | None + reason: str | None + error: Exception | None + + +class OTLPHTTPClient: + """Sends serialized OTLP payloads over HTTP with retry logic. + + Compression, backoff, and connection-error recovery are handled internally. + Callers interact through the :meth:`export` and :meth:`close` methods. + """ + + def __init__( + self, + transport: BaseHTTPTransport, + endpoint: str, + kind: Literal["spans", "logs", "metrics"], + timeout: float = _DEFAULT_TIMEOUT, + compression: Compression = Compression.NONE, + shutdown_event: threading.Event | None = None, + headers: Mapping[str, str] | None = None, + jitter: float = _DEFAULT_JITTER, + logger: logging.Logger | None = None, + ) -> None: + self._transport = transport + self._endpoint = endpoint + self._timeout = timeout + self._compression = compression + self._shutdown_event = ( + shutdown_event if shutdown_event is not None else threading.Event() + ) + self._headers = dict(headers) if headers is not None else {} + self._kind = kind + self._jitter = min(max(jitter, 0.0), 1.0) + self._logger = logger if logger is not None else _logger + + def _compute_backoff(self, retry: int) -> float: + return 2**retry * random.uniform(1 - self._jitter, 1 + self._jitter) + + def _compress(self, serialized_data: bytes) -> bytes: + if self._compression is Compression.GZIP: + buf = BytesIO() + with gzip.GzipFile(fileobj=buf, mode="w") as gz: + gz.write(serialized_data) + return buf.getvalue() + if self._compression is Compression.DEFLATE: + return zlib.compress(serialized_data) + return serialized_data + + def _submit(self, data: bytes, timeout: float) -> BaseHTTPResult: + deadline = time.time() + timeout + result = self._transport.request( + "POST", + self._endpoint, + headers=self._headers, + data=data, + timeout=timeout, + ) + if ( + result.error is not None + and self._transport.is_connection_error(result.error) + and (remaining := deadline - time.time()) > 0 + ): + # Immediately retry connection errors once without backoff. These + # usually indicate a stale pooled connection that the transport will + # reestablish on the next attempt. + result = self._transport.request( + "POST", + self._endpoint, + headers=self._headers, + data=data, + timeout=remaining, + ) + return result + + def export(self, data: bytes) -> ExportResult: + """Export a serialized payload, retrying on transient failures. + + :param data: Serialized bytes to send. + :returns: An :class:`ExportResult` indicating success or the reason for failure. + """ + data = self._compress(data) + deadline = time.time() + self._timeout + + for retry in range(_MAX_RETRIES): + backoff = self._compute_backoff(retry) + status_code: int | None = None + reason: str | None = None + export_error: Exception | None + retryable: bool + + try: + result = self._submit(data, max(deadline - time.time(), 0.0)) + # pylint: disable-next=broad-exception-caught + except Exception as error: + export_error = error + retryable = False + else: + status_code = result.status_code + reason = result.reason + if status_code is not None and 200 <= status_code < 400: + return ExportResult(True, status_code, reason, None) + export_error = result.error + retryable = ( + _is_retryable(status_code) + if status_code + else self._transport.is_connection_error(result.error) + ) + if ( + retryable + and status_code is not None + and (retry_after := _extract_retry_after(result)) + is not None + ): + backoff = retry_after + + if not retryable: + self._logger.error( + "Failed to export %s batch code: %s, reason: %s", + self._kind, + status_code, + reason or export_error or "unknown", + ) + return ExportResult(False, status_code, reason, export_error) + + if ( + retry + 1 == _MAX_RETRIES + or backoff > (deadline - time.time()) + or self._shutdown_event.is_set() + ): + self._logger.error( + "Failed to export %s batch due to timeout, " + "max retries or shutdown.", + self._kind, + ) + return ExportResult(False, status_code, reason, export_error) + + self._logger.warning( + "Transient error %s encountered while exporting %s batch, retrying in %.2fs.", + reason or export_error, + self._kind, + backoff, + ) + shutdown = self._shutdown_event.wait(backoff) + if shutdown: + self._logger.warning("Shutdown in progress, aborting retry.") + break + + return ExportResult(False, None, None, None) + + def close(self) -> None: + """Close the underlying transport and release its resources.""" + self._transport.close() diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/py.typed b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/py.typed new file mode 100644 index 00000000000..e69de29bb2d diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py new file mode 100644 index 00000000000..13e069be44f --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py @@ -0,0 +1,4 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +__version__ = "0.64b0.dev" diff --git a/exporter/opentelemetry-exporter-otlp-common/test-requirements.in b/exporter/opentelemetry-exporter-otlp-common/test-requirements.in new file mode 100644 index 00000000000..ddc84d4adf0 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/test-requirements.in @@ -0,0 +1,10 @@ +iniconfig==2.3.0 +mocket==3.14.1 +packaging==26.2 +pluggy==1.6.0 +pytest==7.4.4 +-e opentelemetry-api +-e opentelemetry-sdk +-e opentelemetry-semantic-conventions +-e exporter/opentelemetry-exporter-http-transport[urllib3,requests] +-e exporter/opentelemetry-exporter-otlp-common diff --git a/exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt b/exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt new file mode 100644 index 00000000000..6618072af25 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt @@ -0,0 +1,69 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile --python 3.10 --universal --resolution highest exporter/opentelemetry-exporter-otlp-common/test-requirements.in -o exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt +-e exporter/opentelemetry-exporter-http-transport + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # opentelemetry-exporter-otlp-common +-e exporter/opentelemetry-exporter-otlp-common + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +-e opentelemetry-api + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # opentelemetry-sdk + # opentelemetry-semantic-conventions +-e opentelemetry-sdk + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +-e opentelemetry-semantic-conventions + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # opentelemetry-sdk +certifi==2026.5.20 + # via requests +charset-normalizer==3.4.7 + # via requests +colorama==0.4.6 ; sys_platform == 'win32' + # via pytest +decorator==5.3.1 + # via mocket +exceptiongroup==1.3.1 ; python_full_version < '3.11' + # via pytest +h11==0.16.0 + # via mocket +idna==3.16 + # via requests +iniconfig==2.3.0 + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # pytest +mocket==3.14.1 + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +packaging==26.2 + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # pytest +pluggy==1.6.0 + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # pytest +puremagic==1.30 ; python_full_version < '3.12' + # via mocket +puremagic==2.2.0 ; python_full_version >= '3.12' + # via mocket +pytest==7.4.4 + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +requests==2.32.3 + # via opentelemetry-exporter-http-transport +tomli==2.4.1 ; python_full_version < '3.11' + # via pytest +typing-extensions==4.15.0 + # via + # exceptiongroup + # mocket + # opentelemetry-api + # opentelemetry-sdk + # opentelemetry-semantic-conventions +urllib3==2.7.0 + # via + # mocket + # opentelemetry-exporter-http-transport + # requests diff --git a/exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt b/exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt new file mode 100644 index 00000000000..9ee31a2d561 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt @@ -0,0 +1,69 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile --python 3.10 --universal --resolution lowest-direct exporter/opentelemetry-exporter-otlp-common/test-requirements.in -o exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt +-e exporter/opentelemetry-exporter-http-transport + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # opentelemetry-exporter-otlp-common +-e exporter/opentelemetry-exporter-otlp-common + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +-e opentelemetry-api + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # opentelemetry-sdk + # opentelemetry-semantic-conventions +-e opentelemetry-sdk + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +-e opentelemetry-semantic-conventions + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # opentelemetry-sdk +certifi==2026.5.20 + # via requests +chardet==3.0.4 + # via requests +colorama==0.4.6 ; sys_platform == 'win32' + # via pytest +decorator==5.3.1 + # via mocket +exceptiongroup==1.3.1 ; python_full_version < '3.11' + # via pytest +h11==0.16.0 + # via mocket +idna==2.10 + # via requests +iniconfig==2.3.0 + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # pytest +mocket==3.14.1 + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +packaging==26.2 + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # pytest +pluggy==1.6.0 + # via + # -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in + # pytest +puremagic==1.30 ; python_full_version < '3.12' + # via mocket +puremagic==2.2.0 ; python_full_version >= '3.12' + # via mocket +pytest==7.4.4 + # via -r exporter/opentelemetry-exporter-otlp-common/test-requirements.in +requests==2.25.0 + # via opentelemetry-exporter-http-transport +tomli==2.4.1 ; python_full_version < '3.11' + # via pytest +typing-extensions==4.15.0 + # via + # exceptiongroup + # mocket + # opentelemetry-api + # opentelemetry-sdk + # opentelemetry-semantic-conventions +urllib3==1.26.0 + # via + # mocket + # opentelemetry-exporter-http-transport + # requests diff --git a/exporter/opentelemetry-exporter-otlp-common/tests/__init__.py b/exporter/opentelemetry-exporter-otlp-common/tests/__init__.py new file mode 100644 index 00000000000..e57cf4aba95 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/tests/__init__.py @@ -0,0 +1,2 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 diff --git a/exporter/opentelemetry-exporter-otlp-common/tests/test_aggregation.py b/exporter/opentelemetry-exporter-otlp-common/tests/test_aggregation.py new file mode 100644 index 00000000000..4883eefb3e2 --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/tests/test_aggregation.py @@ -0,0 +1,151 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 +# pylint: disable=import-error + +import unittest +from unittest.mock import patch + +from opentelemetry.exporter.otlp.common._aggregation import ( + _get_aggregation, + _get_temporality, +) +from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION, + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, +) +from opentelemetry.sdk.metrics import ( + Counter, + Histogram, + ObservableCounter, + ObservableGauge, + ObservableUpDownCounter, + UpDownCounter, +) +from opentelemetry.sdk.metrics.export import AggregationTemporality +from opentelemetry.sdk.metrics.view import ( + ExplicitBucketHistogramAggregation, + ExponentialBucketHistogramAggregation, +) + +_AGGREGATION_LOGGER_NAME = "opentelemetry.exporter.otlp.common._aggregation" + + +class TestGetTemporality(unittest.TestCase): + def test_temporality_default_is_cumulative(self): + result = _get_temporality(None) + for instrument_class in ( + Counter, + UpDownCounter, + Histogram, + ObservableCounter, + ObservableUpDownCounter, + ObservableGauge, + ): + with self.subTest(instrument=instrument_class.__name__): + self.assertEqual( + result[instrument_class], + AggregationTemporality.CUMULATIVE, + ) + + def test_temporality_delta_env(self): + delta_cases = { + Counter: AggregationTemporality.DELTA, + UpDownCounter: AggregationTemporality.CUMULATIVE, + Histogram: AggregationTemporality.DELTA, + ObservableCounter: AggregationTemporality.DELTA, + ObservableUpDownCounter: AggregationTemporality.CUMULATIVE, + ObservableGauge: AggregationTemporality.CUMULATIVE, + } + with patch.dict( + "os.environ", + {OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "DELTA"}, + ): + result = _get_temporality(None) + for instrument_class, expected in delta_cases.items(): + with self.subTest(instrument=instrument_class.__name__): + self.assertEqual(result[instrument_class], expected) + + def test_temporality_lowmemory_env(self): + lowmemory_cases = { + Counter: AggregationTemporality.DELTA, + UpDownCounter: AggregationTemporality.CUMULATIVE, + Histogram: AggregationTemporality.DELTA, + ObservableCounter: AggregationTemporality.CUMULATIVE, + ObservableUpDownCounter: AggregationTemporality.CUMULATIVE, + ObservableGauge: AggregationTemporality.CUMULATIVE, + } + with patch.dict( + "os.environ", + {OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "LOWMEMORY"}, + ): + result = _get_temporality(None) + for instrument_class, expected in lowmemory_cases.items(): + with self.subTest(instrument=instrument_class.__name__): + self.assertEqual(result[instrument_class], expected) + + def test_temporality_invalid_env_logs_warning(self): + with patch.dict( + "os.environ", + {OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "INVALID"}, + ): + with self.assertLogs(_AGGREGATION_LOGGER_NAME, level="WARNING"): + result = _get_temporality(None) + self.assertEqual( + result[Counter], + AggregationTemporality.CUMULATIVE, + ) + + def test_temporality_override_takes_precedence(self): + with patch.dict( + "os.environ", + {OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: "CUMULATIVE"}, + ): + result = _get_temporality({Counter: AggregationTemporality.DELTA}) + self.assertEqual(result[Counter], AggregationTemporality.DELTA) + + +class TestGetAggregation(unittest.TestCase): + def test_aggregation_default_is_explicit_bucket(self): + result = _get_aggregation(None) + self.assertIsInstance( + result[Histogram], + ExplicitBucketHistogramAggregation, + ) + + def test_aggregation_exponential_env(self): + with patch.dict( + "os.environ", + { + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION: "base2_exponential_bucket_histogram" + }, + ): + result = _get_aggregation(None) + self.assertIsInstance( + result[Histogram], + ExponentialBucketHistogramAggregation, + ) + + def test_aggregation_invalid_env_logs_warning(self): + with patch.dict( + "os.environ", + { + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION: "unknown_aggregation" + }, + ): + with self.assertLogs(_AGGREGATION_LOGGER_NAME, level="WARNING"): + result = _get_aggregation(None) + self.assertIsInstance( + result[Histogram], + ExplicitBucketHistogramAggregation, + ) + + def test_aggregation_override_takes_precedence(self): + custom_aggregation = ExponentialBucketHistogramAggregation() + with patch.dict( + "os.environ", + { + OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION: "explicit_bucket_histogram" + }, + ): + result = _get_aggregation({Histogram: custom_aggregation}) + self.assertIs(result[Histogram], custom_aggregation) diff --git a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py new file mode 100644 index 00000000000..a549423f05d --- /dev/null +++ b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py @@ -0,0 +1,462 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# pylint: disable=unexpected-keyword-arg + +import gzip +import threading +import unittest +import zlib +from collections.abc import Callable, Iterator +from contextlib import contextmanager +from dataclasses import dataclass, field +from unittest.mock import Mock, patch + +# pylint: disable-next=import-error +from opentelemetry.exporter.http.transport._base import ( + BaseHTTPResult, + BaseHTTPTransport, +) + +# pylint: disable-next=import-error +from opentelemetry.exporter.otlp.common._http import ( + Compression, + OTLPHTTPClient, +) + + +@contextmanager +def _mock_clock( + shutdown_event: Mock | None = None, +) -> Iterator[Callable[[float], None]]: + _now = [0.0] + + def advance(delta: float) -> None: + _now[0] += delta + + def get_time() -> float: + return _now[0] + + if shutdown_event is not None: + + def _wait(duration: float) -> bool: + advance(duration) + return False + + shutdown_event.wait.side_effect = _wait + + with patch( + "opentelemetry.exporter.otlp.common._http.time.time", + side_effect=get_time, + ): + yield advance + + +@dataclass(frozen=True, slots=True) +class _TestHTTPResult(BaseHTTPResult): + response_headers: dict = field(default_factory=dict) + + # pylint: disable-next=no-self-use + def content(self) -> bytes: + return b"" + + def headers(self): + return self.response_headers + + +class _TestHTTPTransport(BaseHTTPTransport): + def __init__(self, *results, connection_errors=()): + self.results = list(results) + self.requests = [] + self.closed = False + self._connection_errors = set(connection_errors) + + def request( + self, + method, + url, + *, + headers=None, + timeout=None, + data=None, + ): + self.requests.append( + { + "method": method, + "url": url, + "headers": headers, + "timeout": timeout, + "data": data, + } + ) + result = self.results.pop(0) + if callable(result): + result = result() + if isinstance(result, Exception): + raise result + return result + + def is_connection_error(self, exception): + return exception in self._connection_errors + + def close(self): + self.closed = True + + +class TestOTLPHTTPClient(unittest.TestCase): + @staticmethod + def _client( + transport, + *, + timeout=5.0, + compression=Compression.NONE, + shutdown_event=None, + jitter=0.0, + ): + return OTLPHTTPClient( + transport=transport, + endpoint="http://example.test/v1/traces", + timeout=timeout, + compression=compression, + shutdown_event=shutdown_event or threading.Event(), + headers={"content-type": "application/x-protobuf"}, + kind="spans", + jitter=jitter, + ) + + def test_export_success_status_codes(self): + cases = ( + (200, "OK"), + (204, "No Content"), + (302, "Found"), + ) + + for status_code, reason in cases: + with self.subTest(status_code=status_code): + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=status_code, reason=reason) + ) + client = self._client(transport) + + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(result.status_code, status_code) + self.assertEqual(result.reason, reason) + self.assertIsNone(result.error) + + @patch( + "opentelemetry.exporter.otlp.common._http.time.time", + side_effect=(100.0, 100.0, 100.0), + ) + def test_export_request_arguments(self, mock_time): + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=200, reason="OK") + ) + client = self._client(transport, timeout=3.0) + + client.export(b"payload") + + self.assertEqual(len(transport.requests), 1) + self.assertEqual( + transport.requests[0], + { + "method": "POST", + "url": "http://example.test/v1/traces", + "headers": {"content-type": "application/x-protobuf"}, + "timeout": 3.0, + "data": b"payload", + }, + ) + self.assertEqual(mock_time.call_count, 3) + + def test_export_compresses_payload(self): + cases = ( + ( + Compression.NONE, + lambda data: data, + ), + ( + Compression.GZIP, + gzip.decompress, + ), + ( + Compression.DEFLATE, + zlib.decompress, + ), + ) + + for compression, decompress in cases: + with self.subTest(compression=compression): + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=200, reason="OK") + ) + client = self._client(transport, compression=compression) + + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual( + decompress(transport.requests[0]["data"]), b"payload" + ) + + def test_export_retryable_status_codes(self): + cases = ( + (429, "Too Many Requests"), + (502, "Bad Gateway"), + (503, "Service Unavailable"), + (504, "Gateway Timeout"), + ) + + for status_code, reason in cases: + with self.subTest(status_code=status_code): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + shutdown_event.wait.return_value = False + transport = _TestHTTPTransport( + _TestHTTPResult( + status_code=status_code, + reason=reason, + ), + _TestHTTPResult(status_code=200, reason="OK"), + ) + client = self._client( + transport, + shutdown_event=shutdown_event, + ) + + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + shutdown_event.wait.assert_called_once_with(1.0) + + def test_export_connection_errors(self): + error = RuntimeError("connection failed") + transport = _TestHTTPTransport( + _TestHTTPResult(error=error), + _TestHTTPResult(status_code=200, reason="OK"), + connection_errors={error}, + ) + client = self._client(transport) + + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + self.assertAlmostEqual(transport.requests[0]["timeout"], 5.0, 2) + self.assertLessEqual( + transport.requests[1]["timeout"], + transport.requests[0]["timeout"], + ) + self.assertGreater(transport.requests[1]["timeout"], 0.0) + + def test_export_non_retryable_errors(self): + exception = RuntimeError("request failed") + cases = ( + ( + _TestHTTPResult(status_code=400, reason="Bad Request"), + 400, + "Bad Request", + None, + ), + ( + _TestHTTPResult(status_code=408, reason="Request Timeout"), + 408, + "Request Timeout", + None, + ), + ( + _TestHTTPResult( + status_code=500, reason="Internal Server Error" + ), + 500, + "Internal Server Error", + None, + ), + ( + _TestHTTPResult(error=exception), + None, + None, + exception, + ), + ( + exception, + None, + None, + exception, + ), + ) + + for ( + response, + expected_status_code, + expected_reason, + expected_error, + ) in cases: + with self.subTest(response=type(response).__name__): + transport = _TestHTTPTransport(response) + client = self._client(transport) + + result = client.export(b"payload") + + self.assertFalse(result.success) + self.assertEqual(result.status_code, expected_status_code) + self.assertEqual(result.reason, expected_reason) + self.assertIs(result.error, expected_error) + + def test_export_with_shutdown(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = True + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=503, reason="Service Unavailable") + ) + client = self._client(transport, shutdown_event=shutdown_event) + + result = client.export(b"payload") + + self.assertFalse(result.success) + self.assertEqual(result.status_code, 503) + self.assertEqual(result.reason, "Service Unavailable") + shutdown_event.wait.assert_not_called() + + def test_close_closes_transport(self): + transport = _TestHTTPTransport() + client = self._client(transport) + + client.close() + + self.assertTrue(transport.closed) + + def test_export_timeout_decreases_per_retry(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=503, reason="Service Unavailable"), + _TestHTTPResult(status_code=503, reason="Service Unavailable"), + _TestHTTPResult(status_code=200, reason="OK"), + ) + client = self._client( + transport, timeout=10.0, jitter=0.0, shutdown_event=shutdown_event + ) + + with _mock_clock(shutdown_event): + result = client.export(b"payload") + + # retry=0: wait(1.0) -> time=1.0, retry=1: wait(2.0) -> time=3.0, success + self.assertTrue(result.success) + self.assertAlmostEqual(transport.requests[0]["timeout"], 10.0) + self.assertAlmostEqual(transport.requests[1]["timeout"], 9.0) + self.assertAlmostEqual(transport.requests[2]["timeout"], 7.0) + + def test_export_backoff_exhausts_remaining_timeout(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=503, reason="Service Unavailable"), + _TestHTTPResult(status_code=503, reason="Service Unavailable"), + ) + # timeout=1.5: retry=0 backoff=1.0 fits -> wait(1.0) -> time=1.0 + # retry=1 backoff=2.0 > 0.5 remaining -> give up + client = self._client( + transport, timeout=1.5, jitter=0.0, shutdown_event=shutdown_event + ) + + with _mock_clock(shutdown_event): + result = client.export(b"payload") + + self.assertFalse(result.success) + self.assertEqual(result.status_code, 503) + self.assertEqual(len(transport.requests), 2) + shutdown_event.wait.assert_called_once_with(1.0) + + def test_export_exhausts_max_retries(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + transport = _TestHTTPTransport( + *[_TestHTTPResult(status_code=503, reason="Service Unavailable")] + * 6 + ) + client = self._client( + transport, + timeout=1000.0, + jitter=0.0, + shutdown_event=shutdown_event, + ) + + with _mock_clock(shutdown_event): + result = client.export(b"payload") + + self.assertFalse(result.success) + self.assertEqual(len(transport.requests), 6) + self.assertEqual(shutdown_event.wait.call_count, 5) + self.assertEqual( + [call.args[0] for call in shutdown_event.wait.call_args_list], + [1.0, 2.0, 4.0, 8.0, 16.0], + ) + + def test_export_connection_error_gets_reduced_timeout(self): + stale_error = RuntimeError("stale connection") + transport = _TestHTTPTransport( + _TestHTTPResult(status_code=200, reason="OK"), + connection_errors={stale_error}, + ) + + with _mock_clock() as advance: + + def _slow_connection_error() -> _TestHTTPResult: + advance(2.0) + return _TestHTTPResult(error=stale_error) + + transport.results.insert(0, _slow_connection_error) + client = self._client(transport, timeout=5.0) + result = client.export(b"payload") + + # _submit: deadline=0+5=5.0, after first request time=2.0, remaining=3.0 + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + self.assertAlmostEqual(transport.requests[1]["timeout"], 3.0) + + def test_export_retry_after_header_used_as_backoff(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + shutdown_event.wait.return_value = False + transport = _TestHTTPTransport( + _TestHTTPResult( + status_code=429, + reason="Too Many Requests", + response_headers={"retry-after": "5"}, + ), + _TestHTTPResult(status_code=200, reason="OK"), + ) + client = self._client( + transport, timeout=60.0, shutdown_event=shutdown_event + ) + + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + shutdown_event.wait.assert_called_once_with(5.0) + + def test_export_retry_after_header_exhausts_timeout(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + transport = _TestHTTPTransport( + _TestHTTPResult( + status_code=503, + reason="Service Unavailable", + response_headers={"retry-after": "10"}, + ), + ) + client = self._client( + transport, timeout=3.0, jitter=0.0, shutdown_event=shutdown_event + ) + + with _mock_clock(shutdown_event): + result = client.export(b"payload") + + self.assertFalse(result.success) + self.assertEqual(result.status_code, 503) + self.assertEqual(len(transport.requests), 1) + shutdown_event.wait.assert_not_called() diff --git a/tox.ini b/tox.ini index 5476de0cde1..8dfbf96b39b 100644 --- a/tox.ini +++ b/tox.ini @@ -48,6 +48,10 @@ envlist = ; exporter-http-transport intentionally excluded from pypy3 lint-opentelemetry-exporter-http-transport + py3{10,11,12,13,14,14t}-test-opentelemetry-exporter-otlp-common-{oldest,latest} + ; exporter-otlp-common intentionally excluded from pypy3 + lint-opentelemetry-exporter-otlp-common-latest + py3{10,11,12,13,14}-test-opentelemetry-exporter-opencensus ; exporter-opencensus intentionally excluded from pypy3 lint-opentelemetry-exporter-opencensus @@ -147,6 +151,9 @@ deps = opentelemetry-exporter-http-transport-oldest: -r {toxinidir}/exporter/opentelemetry-exporter-http-transport/test-requirements.oldest.txt opentelemetry-exporter-http-transport-latest: -r {toxinidir}/exporter/opentelemetry-exporter-http-transport/test-requirements.latest.txt + opentelemetry-exporter-otlp-common-oldest: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt + opentelemetry-exporter-otlp-common-latest: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt + exporter-opencensus: -r {toxinidir}/exporter/opentelemetry-exporter-opencensus/test-requirements.txt exporter-otlp-proto-common: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements.txt @@ -246,6 +253,9 @@ commands = test-opentelemetry-exporter-http-transport: pytest {toxinidir}/exporter/opentelemetry-exporter-http-transport/tests {posargs} lint-opentelemetry-exporter-http-transport: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-http-transport" + test-opentelemetry-exporter-otlp-common: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-common/tests {posargs} + lint-opentelemetry-exporter-otlp-common: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp-common" + test-opentelemetry-exporter-opencensus: pytest {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests {posargs} lint-opentelemetry-exporter-opencensus: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-opencensus" diff --git a/uv.lock b/uv.lock index 4bb08fd62ad..3cf4ae773a1 100644 --- a/uv.lock +++ b/uv.lock @@ -13,6 +13,7 @@ members = [ "opentelemetry-codegen-json", "opentelemetry-exporter-http-transport", "opentelemetry-exporter-otlp", + "opentelemetry-exporter-otlp-common", "opentelemetry-exporter-otlp-json-common", "opentelemetry-exporter-otlp-json-file", "opentelemetry-exporter-otlp-proto-common", @@ -33,7 +34,7 @@ members = [ [[package]] name = "annotated-types" version = "0.7.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, @@ -42,7 +43,7 @@ wheels = [ [[package]] name = "anyio" version = "4.13.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "idna" }, @@ -56,7 +57,7 @@ wheels = [ [[package]] name = "argcomplete" version = "3.6.3" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/38/61/0b9ae6399dd4a58d8c1b1dc5a27d6f2808023d0b5dd3104bb99f45a33ff6/argcomplete-3.6.3.tar.gz", hash = "sha256:62e8ed4fd6a45864acc8235409461b72c9a28ee785a2011cc5eb78318786c89c", size = 73754, upload-time = "2025-10-20T03:33:34.741Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/74/f5/9373290775639cb67a2fce7f629a1c240dce9f12fe927bc32b2736e16dfc/argcomplete-3.6.3-py3-none-any.whl", hash = "sha256:f5007b3a600ccac5d25bbce33089211dfd49eab4a7718da3f10e3082525a92ce", size = 43846, upload-time = "2025-10-20T03:33:33.021Z" }, @@ -65,7 +66,7 @@ wheels = [ [[package]] name = "asgiref" version = "3.11.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] @@ -77,7 +78,7 @@ wheels = [ [[package]] name = "attrs" version = "26.1.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", hash = "sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32", size = 952055, upload-time = "2026-03-19T14:22:25.026Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309", size = 67548, upload-time = "2026-03-19T14:22:23.645Z" }, @@ -86,7 +87,7 @@ wheels = [ [[package]] name = "black" version = "26.3.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "click" }, { name = "mypy-extensions" }, @@ -130,7 +131,7 @@ wheels = [ [[package]] name = "cachetools" version = "7.0.5" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/af/dd/57fe3fdb6e65b25a5987fd2cdc7e22db0aef508b91634d2e57d22928d41b/cachetools-7.0.5.tar.gz", hash = "sha256:0cd042c24377200c1dcd225f8b7b12b0ca53cc2c961b43757e774ebe190fd990", size = 37367, upload-time = "2026-03-09T20:51:29.451Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/06/f3/39cf3367b8107baa44f861dc802cbf16263c945b62d8265d36034fc07bea/cachetools-7.0.5-py3-none-any.whl", hash = "sha256:46bc8ebefbe485407621d0a4264b23c080cedd913921bad7ac3ed2f26c183114", size = 13918, upload-time = "2026-03-09T20:51:27.33Z" }, @@ -139,7 +140,7 @@ wheels = [ [[package]] name = "certifi" version = "2026.2.25" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/af/2d/7bf41579a8986e348fa033a31cdd0e4121114f6bce2457e8876010b092dd/certifi-2026.2.25.tar.gz", hash = "sha256:e887ab5cee78ea814d3472169153c2d12cd43b14bd03329a39a9c6e2e80bfba7", size = 155029, upload-time = "2026-02-25T02:54:17.342Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/9a/3c/c17fb3ca2d9c3acff52e30b309f538586f9f5b9c9cf454f3845fc9af4881/certifi-2026.2.25-py3-none-any.whl", hash = "sha256:027692e4402ad994f1c42e52a4997a9763c646b73e4096e4d5d6db8af1d6f0fa", size = 153684, upload-time = "2026-02-25T02:54:15.766Z" }, @@ -148,7 +149,7 @@ wheels = [ [[package]] name = "cffi" version = "2.0.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pycparser", marker = "implementation_name != 'PyPy'" }, ] @@ -230,7 +231,7 @@ wheels = [ [[package]] name = "cfgv" version = "3.5.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/4e/b5/721b8799b04bf9afe054a3899c6cf4e880fcf8563cc71c15610242490a0c/cfgv-3.5.0.tar.gz", hash = "sha256:d5b1034354820651caa73ede66a6294d6e95c1b00acc5e9b098e917404669132", size = 7334, upload-time = "2025-11-19T20:55:51.612Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/db/3c/33bac158f8ab7f89b2e59426d5fe2e4f63f7ed25df84c036890172b412b5/cfgv-3.5.0-py2.py3-none-any.whl", hash = "sha256:a8dc6b26ad22ff227d2634a65cb388215ce6cc96bbcc5cfde7641ae87e8dacc0", size = 7445, upload-time = "2025-11-19T20:55:50.744Z" }, @@ -239,7 +240,7 @@ wheels = [ [[package]] name = "charset-normalizer" version = "3.4.7" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/e7/a1/67fe25fac3c7642725500a3f6cfe5821ad557c3abb11c9d20d12c7008d3e/charset_normalizer-3.4.7.tar.gz", hash = "sha256:ae89db9e5f98a11a4bf50407d4363e7b09b31e55bc117b4f7d80aab97ba009e5", size = 144271, upload-time = "2026-04-02T09:28:39.342Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/26/08/0f303cb0b529e456bb116f2d50565a482694fbb94340bf56d44677e7ed03/charset_normalizer-3.4.7-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cdd68a1fb318e290a2077696b7eb7a21a49163c455979c639bf5a5dcdc46617d", size = 315182, upload-time = "2026-04-02T09:25:40.673Z" }, @@ -344,7 +345,7 @@ wheels = [ [[package]] name = "click" version = "8.3.2" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] @@ -356,7 +357,7 @@ wheels = [ [[package]] name = "colorama" version = "0.4.6" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, @@ -365,7 +366,7 @@ wheels = [ [[package]] name = "cryptography" version = "46.0.7" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cffi", marker = "platform_python_implementation != 'PyPy'" }, { name = "typing-extensions", marker = "python_full_version < '3.11'" }, @@ -425,7 +426,7 @@ wheels = [ [[package]] name = "datamodel-code-generator" version = "0.56.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "argcomplete" }, { name = "black" }, @@ -453,7 +454,7 @@ ruff = [ [[package]] name = "distlib" version = "0.4.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/96/8e/709914eb2b5749865801041647dc7f4e6d00b549cfe88b65ca192995f07c/distlib-0.4.0.tar.gz", hash = "sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d", size = 614605, upload-time = "2025-07-17T16:52:00.465Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/33/6b/e0547afaf41bf2c42e52430072fa5658766e3d65bd4b03a563d1b6336f57/distlib-0.4.0-py2.py3-none-any.whl", hash = "sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16", size = 469047, upload-time = "2025-07-17T16:51:58.613Z" }, @@ -462,7 +463,7 @@ wheels = [ [[package]] name = "exceptiongroup" version = "1.3.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions", marker = "python_full_version < '3.13'" }, ] @@ -474,7 +475,7 @@ wheels = [ [[package]] name = "filelock" version = "3.25.2" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/94/b8/00651a0f559862f3bb7d6f7477b192afe3f583cc5e26403b44e59a55ab34/filelock-3.25.2.tar.gz", hash = "sha256:b64ece2b38f4ca29dd3e810287aa8c48182bbecd1ae6e9ae126c9b35f1382694", size = 40480, upload-time = "2026-03-11T20:45:38.487Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/a4/a5/842ae8f0c08b61d6484b52f99a03510a3a72d23141942d216ebe81fefbce/filelock-3.25.2-py3-none-any.whl", hash = "sha256:ca8afb0da15f229774c9ad1b455ed96e85a81373065fb10446672f64444ddf70", size = 26759, upload-time = "2026-03-11T20:45:37.437Z" }, @@ -483,7 +484,7 @@ wheels = [ [[package]] name = "genson" version = "1.3.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/c5/cf/2303c8ad276dcf5ee2ad6cf69c4338fd86ef0f471a5207b069adf7a393cf/genson-1.3.0.tar.gz", hash = "sha256:e02db9ac2e3fd29e65b5286f7135762e2cd8a986537c075b06fc5f1517308e37", size = 34919, upload-time = "2024-05-15T22:08:49.123Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/f8/5c/e226de133afd8bb267ec27eead9ae3d784b95b39a287ed404caab39a5f50/genson-1.3.0-py3-none-any.whl", hash = "sha256:468feccd00274cc7e4c09e84b08704270ba8d95232aa280f65b986139cec67f7", size = 21470, upload-time = "2024-05-15T22:08:47.056Z" }, @@ -492,7 +493,7 @@ wheels = [ [[package]] name = "google-auth" version = "2.49.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cryptography" }, { name = "pyasn1-modules" }, @@ -505,7 +506,7 @@ wheels = [ [[package]] name = "googleapis-common-protos" version = "1.74.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "protobuf" }, ] @@ -517,7 +518,7 @@ wheels = [ [[package]] name = "grpcio" version = "1.80.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] @@ -578,7 +579,7 @@ wheels = [ [[package]] name = "h11" version = "0.16.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, @@ -587,7 +588,7 @@ wheels = [ [[package]] name = "httpcore" version = "1.0.9" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "certifi" }, { name = "h11" }, @@ -600,7 +601,7 @@ wheels = [ [[package]] name = "httpx" version = "0.28.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, { name = "certifi" }, @@ -615,7 +616,7 @@ wheels = [ [[package]] name = "identify" version = "2.6.18" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/46/c4/7fb4db12296cdb11893d61c92048fe617ee853f8523b9b296ac03b43757e/identify-2.6.18.tar.gz", hash = "sha256:873ac56a5e3fd63e7438a7ecbc4d91aca692eb3fefa4534db2b7913f3fc352fd", size = 99580, upload-time = "2026-03-15T18:39:50.319Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/46/33/92ef41c6fad0233e41d3d84ba8e8ad18d1780f1e5d99b3c683e6d7f98b63/identify-2.6.18-py2.py3-none-any.whl", hash = "sha256:8db9d3c8ea9079db92cafb0ebf97abdc09d52e97f4dcf773a2e694048b7cd737", size = 99394, upload-time = "2026-03-15T18:39:48.915Z" }, @@ -624,7 +625,7 @@ wheels = [ [[package]] name = "idna" version = "3.11" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, @@ -633,7 +634,7 @@ wheels = [ [[package]] name = "inflect" version = "7.5.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "more-itertools" }, { name = "typeguard" }, @@ -646,7 +647,7 @@ wheels = [ [[package]] name = "isort" version = "8.0.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/ef/7c/ec4ab396d31b3b395e2e999c8f46dec78c5e29209fac49d1f4dace04041d/isort-8.0.1.tar.gz", hash = "sha256:171ac4ff559cdc060bcfff550bc8404a486fee0caab245679c2abe7cb253c78d", size = 769592, upload-time = "2026-02-28T10:08:20.685Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/3e/95/c7c34aa53c16353c56d0b802fba48d5f5caa2cdee7958acbcb795c830416/isort-8.0.1-py3-none-any.whl", hash = "sha256:28b89bc70f751b559aeca209e6120393d43fbe2490de0559662be7a9787e3d75", size = 89733, upload-time = "2026-02-28T10:08:19.466Z" }, @@ -655,7 +656,7 @@ wheels = [ [[package]] name = "jinja2" version = "3.1.6" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markupsafe" }, ] @@ -667,7 +668,7 @@ wheels = [ [[package]] name = "jsonschema" version = "4.26.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "attrs" }, { name = "jsonschema-specifications" }, @@ -682,7 +683,7 @@ wheels = [ [[package]] name = "jsonschema-specifications" version = "2025.9.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "referencing" }, ] @@ -694,7 +695,7 @@ wheels = [ [[package]] name = "markupsafe" version = "3.0.3" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload-time = "2025-09-27T18:37:40.426Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/e8/4b/3541d44f3937ba468b75da9eebcae497dcf67adb65caa16760b0a6807ebb/markupsafe-3.0.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2f981d352f04553a7171b8e44369f2af4055f888dfb147d55e42d29e29e74559", size = 11631, upload-time = "2025-09-27T18:36:05.558Z" }, @@ -779,7 +780,7 @@ wheels = [ [[package]] name = "more-itertools" version = "11.0.2" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/a2/f7/139d22fef48ac78127d18e01d80cf1be40236ae489769d17f35c3d425293/more_itertools-11.0.2.tar.gz", hash = "sha256:392a9e1e362cbc106a2457d37cabf9b36e5e12efd4ebff1654630e76597df804", size = 144659, upload-time = "2026-04-09T15:01:33.297Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/cb/98/6af411189d9413534c3eb691182bff1f5c6d44ed2f93f2edfe52a1bbceb8/more_itertools-11.0.2-py3-none-any.whl", hash = "sha256:6e35b35f818b01f691643c6c611bc0902f2e92b46c18fffa77ae1e7c46e912e4", size = 71939, upload-time = "2026-04-09T15:01:32.21Z" }, @@ -788,7 +789,7 @@ wheels = [ [[package]] name = "mypy-extensions" version = "1.1.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, @@ -797,7 +798,7 @@ wheels = [ [[package]] name = "nodeenv" version = "1.10.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/24/bf/d1bda4f6168e0b2e9e5958945e01910052158313224ada5ce1fb2e1113b8/nodeenv-1.10.0.tar.gz", hash = "sha256:996c191ad80897d076bdfba80a41994c2b47c68e224c542b48feba42ba00f8bb", size = 55611, upload-time = "2025-12-20T14:08:54.006Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/88/b2/d0896bdcdc8d28a7fc5717c305f1a861c26e18c05047949fb371034d98bd/nodeenv-1.10.0-py2.py3-none-any.whl", hash = "sha256:5bb13e3eed2923615535339b3c620e76779af4cb4c6a90deccc9e36b274d3827", size = 23438, upload-time = "2025-12-20T14:08:52.782Z" }, @@ -831,7 +832,7 @@ requires-dist = [ [[package]] name = "opentelemetry-exporter-credential-provider-gcp" version = "0.62b0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "google-auth" }, { name = "grpcio" }, @@ -875,6 +876,25 @@ requires-dist = [ { name = "opentelemetry-exporter-otlp-proto-http", editable = "exporter/opentelemetry-exporter-otlp-proto-http" }, ] +[[package]] +name = "opentelemetry-exporter-otlp-common" +source = { editable = "exporter/opentelemetry-exporter-otlp-common" } +dependencies = [ + { name = "opentelemetry-sdk" }, +] + +[package.optional-dependencies] +http = [ + { name = "opentelemetry-exporter-http-transport" }, +] + +[package.metadata] +requires-dist = [ + { name = "opentelemetry-exporter-http-transport", marker = "extra == 'http'", editable = "exporter/opentelemetry-exporter-http-transport" }, + { name = "opentelemetry-sdk", editable = "opentelemetry-sdk" }, +] +provides-extras = ["http"] + [[package]] name = "opentelemetry-exporter-otlp-json-common" source = { editable = "exporter/opentelemetry-exporter-otlp-json-common" } @@ -1171,7 +1191,7 @@ requires-dist = [ [[package]] name = "packaging" version = "26.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/65/ee/299d360cdc32edc7d2cf530f3accf79c4fca01e96ffc950d8a52213bd8e4/packaging-26.0.tar.gz", hash = "sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4", size = 143416, upload-time = "2026-01-21T20:50:39.064Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/b7/b9/c538f279a4e237a006a2c98387d081e9eb060d203d8ed34467cc0f0b9b53/packaging-26.0-py3-none-any.whl", hash = "sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529", size = 74366, upload-time = "2026-01-21T20:50:37.788Z" }, @@ -1180,7 +1200,7 @@ wheels = [ [[package]] name = "pathspec" version = "1.0.4" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/fa/36/e27608899f9b8d4dff0617b2d9ab17ca5608956ca44461ac14ac48b44015/pathspec-1.0.4.tar.gz", hash = "sha256:0210e2ae8a21a9137c0d470578cb0e595af87edaa6ebf12ff176f14a02e0e645", size = 131200, upload-time = "2026-01-27T03:59:46.938Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/ef/3c/2c197d226f9ea224a9ab8d197933f9da0ae0aac5b6e0f884e2b8d9c8e9f7/pathspec-1.0.4-py3-none-any.whl", hash = "sha256:fb6ae2fd4e7c921a165808a552060e722767cfa526f99ca5156ed2ce45a5c723", size = 55206, upload-time = "2026-01-27T03:59:45.137Z" }, @@ -1189,7 +1209,7 @@ wheels = [ [[package]] name = "platformdirs" version = "4.9.6" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/9f/4a/0883b8e3802965322523f0b200ecf33d31f10991d0401162f4b23c698b42/platformdirs-4.9.6.tar.gz", hash = "sha256:3bfa75b0ad0db84096ae777218481852c0ebc6c727b3168c1b9e0118e458cf0a", size = 29400, upload-time = "2026-04-09T00:04:10.812Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/75/a6/a0a304dc33b49145b21f4808d763822111e67d1c3a32b524a1baf947b6e1/platformdirs-4.9.6-py3-none-any.whl", hash = "sha256:e61adb1d5e5cb3441b4b7710bea7e4c12250ca49439228cc1021c00dcfac0917", size = 21348, upload-time = "2026-04-09T00:04:09.463Z" }, @@ -1198,7 +1218,7 @@ wheels = [ [[package]] name = "pluggy" version = "1.6.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, @@ -1207,7 +1227,7 @@ wheels = [ [[package]] name = "pre-commit" version = "4.5.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cfgv" }, { name = "identify" }, @@ -1223,7 +1243,7 @@ wheels = [ [[package]] name = "prometheus-client" version = "0.25.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/1b/fb/d9aa83ffe43ce1f19e557c0971d04b90561b0cfd50762aafb01968285553/prometheus_client-0.25.0.tar.gz", hash = "sha256:5e373b75c31afb3c86f1a52fa1ad470c9aace18082d39ec0d2f918d11cc9ba28", size = 86035, upload-time = "2026-04-09T19:53:42.359Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/8d/9b/d4b1e644385499c8346fa9b622a3f030dce14cd6ef8a1871c221a17a67e7/prometheus_client-0.25.0-py3-none-any.whl", hash = "sha256:d5aec89e349a6ec230805d0df882f3807f74fd6c1a2fa86864e3c2279059fed1", size = 64154, upload-time = "2026-04-09T19:53:41.324Z" }, @@ -1232,7 +1252,7 @@ wheels = [ [[package]] name = "protobuf" version = "6.33.6" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/66/70/e908e9c5e52ef7c3a6c7902c9dfbb34c7e29c25d2f81ade3856445fd5c94/protobuf-6.33.6.tar.gz", hash = "sha256:a6768d25248312c297558af96a9f9c929e8c4cee0659cb07e780731095f38135", size = 444531, upload-time = "2026-03-18T19:05:00.988Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/fc/9f/2f509339e89cfa6f6a4c4ff50438db9ca488dec341f7e454adad60150b00/protobuf-6.33.6-cp310-abi3-win32.whl", hash = "sha256:7d29d9b65f8afef196f8334e80d6bc1d5d4adedb449971fefd3723824e6e77d3", size = 425739, upload-time = "2026-03-18T19:04:48.373Z" }, @@ -1247,7 +1267,7 @@ wheels = [ [[package]] name = "pyasn1" version = "0.6.3" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/5c/5f/6583902b6f79b399c9c40674ac384fd9cd77805f9e6205075f828ef11fb2/pyasn1-0.6.3.tar.gz", hash = "sha256:697a8ecd6d98891189184ca1fa05d1bb00e2f84b5977c481452050549c8a72cf", size = 148685, upload-time = "2026-03-17T01:06:53.382Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/5d/a0/7d793dce3fa811fe047d6ae2431c672364b462850c6235ae306c0efd025f/pyasn1-0.6.3-py3-none-any.whl", hash = "sha256:a80184d120f0864a52a073acc6fc642847d0be408e7c7252f31390c0f4eadcde", size = 83997, upload-time = "2026-03-17T01:06:52.036Z" }, @@ -1256,7 +1276,7 @@ wheels = [ [[package]] name = "pyasn1-modules" version = "0.4.2" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pyasn1" }, ] @@ -1268,7 +1288,7 @@ wheels = [ [[package]] name = "pycparser" version = "3.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/1b/7d/92392ff7815c21062bea51aa7b87d45576f649f16458d78b7cf94b9ab2e6/pycparser-3.0.tar.gz", hash = "sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29", size = 103492, upload-time = "2026-01-21T14:26:51.89Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/0c/c3/44f3fbbfa403ea2a7c779186dc20772604442dde72947e7d01069cbe98e3/pycparser-3.0-py3-none-any.whl", hash = "sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992", size = 48172, upload-time = "2026-01-21T14:26:50.693Z" }, @@ -1277,7 +1297,7 @@ wheels = [ [[package]] name = "pydantic" version = "2.12.5" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "annotated-types" }, { name = "pydantic-core" }, @@ -1292,7 +1312,7 @@ wheels = [ [[package]] name = "pydantic-core" version = "2.41.5" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] @@ -1410,7 +1430,7 @@ wheels = [ [[package]] name = "pyproject-api" version = "1.10.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "packaging" }, { name = "tomli", marker = "python_full_version < '3.11'" }, @@ -1423,7 +1443,7 @@ wheels = [ [[package]] name = "python-discovery" version = "1.2.2" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "filelock" }, { name = "platformdirs" }, @@ -1436,7 +1456,7 @@ wheels = [ [[package]] name = "pytokens" version = "0.4.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/b6/34/b4e015b99031667a7b960f888889c5bd34ef585c85e1cb56a594b92836ac/pytokens-0.4.1.tar.gz", hash = "sha256:292052fe80923aae2260c073f822ceba21f3872ced9a68bb7953b348e561179a", size = 23015, upload-time = "2026-01-30T01:03:45.924Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/42/24/f206113e05cb8ef51b3850e7ef88f20da6f4bf932190ceb48bd3da103e10/pytokens-0.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2a44ed93ea23415c54f3face3b65ef2b844d96aeb3455b8a69b3df6beab6acc5", size = 161522, upload-time = "2026-01-30T01:02:50.393Z" }, @@ -1475,7 +1495,7 @@ wheels = [ [[package]] name = "pyyaml" version = "6.0.3" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/f4/a0/39350dd17dd6d6c6507025c0e53aef67a9293a6d37d3511f23ea510d5800/pyyaml-6.0.3-cp310-cp310-macosx_10_13_x86_64.whl", hash = "sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b", size = 184227, upload-time = "2025-09-25T21:31:46.04Z" }, @@ -1539,7 +1559,7 @@ wheels = [ [[package]] name = "referencing" version = "0.37.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "attrs" }, { name = "rpds-py" }, @@ -1553,7 +1573,7 @@ wheels = [ [[package]] name = "requests" version = "2.33.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "certifi" }, { name = "charset-normalizer" }, @@ -1568,7 +1588,7 @@ wheels = [ [[package]] name = "rpds-py" version = "0.30.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/20/af/3f2f423103f1113b36230496629986e0ef7e199d2aa8392452b484b38ced/rpds_py-0.30.0.tar.gz", hash = "sha256:dd8ff7cf90014af0c0f787eea34794ebf6415242ee1d6fa91eaba725cc441e84", size = 69469, upload-time = "2025-11-30T20:24:38.837Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/06/0c/0c411a0ec64ccb6d104dcabe0e713e05e153a9a2c3c2bd2b32ce412166fe/rpds_py-0.30.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:679ae98e00c0e8d68a7fda324e16b90fd5260945b45d3b824c892cec9eea3288", size = 370490, upload-time = "2025-11-30T20:21:33.256Z" }, @@ -1690,7 +1710,7 @@ wheels = [ [[package]] name = "ruff" version = "0.15.10" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/e7/d9/aa3f7d59a10ef6b14fe3431706f854dbf03c5976be614a9796d36326810c/ruff-0.15.10.tar.gz", hash = "sha256:d1f86e67ebfdef88e00faefa1552b5e510e1d35f3be7d423dc7e84e63788c94e", size = 4631728, upload-time = "2026-04-09T14:06:09.884Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/eb/00/a1c2fdc9939b2c03691edbda290afcd297f1f389196172826b03d6b6a595/ruff-0.15.10-py3-none-linux_armv6l.whl", hash = "sha256:0744e31482f8f7d0d10a11fcbf897af272fefdfcb10f5af907b18c2813ff4d5f", size = 10563362, upload-time = "2026-04-09T14:06:21.189Z" }, @@ -1715,7 +1735,7 @@ wheels = [ [[package]] name = "tomli" version = "2.4.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/22/de/48c59722572767841493b26183a0d1cc411d54fd759c5607c4590b6563a6/tomli-2.4.1.tar.gz", hash = "sha256:7c7e1a961a0b2f2472c1ac5b69affa0ae1132c39adcb67aba98568702b9cc23f", size = 17543, upload-time = "2026-03-25T20:22:03.828Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/f4/11/db3d5885d8528263d8adc260bb2d28ebf1270b96e98f0e0268d32b8d9900/tomli-2.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f8f0fc26ec2cc2b965b7a3b87cd19c5c6b8c5e5f436b984e85f486d652285c30", size = 154704, upload-time = "2026-03-25T20:21:10.473Z" }, @@ -1769,7 +1789,7 @@ wheels = [ [[package]] name = "tomli-w" version = "1.2.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/19/75/241269d1da26b624c0d5e110e8149093c759b7a286138f4efd61a60e75fe/tomli_w-1.2.0.tar.gz", hash = "sha256:2dd14fac5a47c27be9cd4c976af5a12d87fb1f0b4512f81d69cce3b35ae25021", size = 7184, upload-time = "2025-01-15T12:07:24.262Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/c7/18/c86eb8e0202e32dd3df50d43d7ff9854f8e0603945ff398974c1d91ac1ef/tomli_w-1.2.0-py3-none-any.whl", hash = "sha256:188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90", size = 6675, upload-time = "2025-01-15T12:07:22.074Z" }, @@ -1778,7 +1798,7 @@ wheels = [ [[package]] name = "towncrier" version = "25.8.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "click" }, { name = "jinja2" }, @@ -1792,7 +1812,7 @@ wheels = [ [[package]] name = "tox" version = "4.52.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cachetools" }, { name = "colorama" }, @@ -1815,7 +1835,7 @@ wheels = [ [[package]] name = "tox-uv" version = "1.35.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "tox-uv-bare" }, { name = "uv" }, @@ -1827,7 +1847,7 @@ wheels = [ [[package]] name = "tox-uv-bare" version = "1.35.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "packaging" }, { name = "tomli", marker = "python_full_version < '3.11'" }, @@ -1841,7 +1861,7 @@ wheels = [ [[package]] name = "typeguard" version = "4.5.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] @@ -1853,7 +1873,7 @@ wheels = [ [[package]] name = "types-protobuf" version = "7.34.1.20260408" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/5b/b1/4521e68c2cc17703d80eb42796751345376dd4c706f84007ef5e7c707774/types_protobuf-7.34.1.20260408.tar.gz", hash = "sha256:e2c0a0430e08c75b52671a6f0035abfdcc791aad12af16274282de1b721758ab", size = 68835, upload-time = "2026-04-08T04:26:43.613Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/ef/b5/0bc9874d89c58fb0ce851e150055ce732d254dbb10b06becbc7635d0d635/types_protobuf-7.34.1.20260408-py3-none-any.whl", hash = "sha256:ebbcd4e27b145aef6a59bc0cb6c013b3528151c1ba5e7f7337aeee355d276a5e", size = 86012, upload-time = "2026-04-08T04:26:42.566Z" }, @@ -1862,7 +1882,7 @@ wheels = [ [[package]] name = "typing-extensions" version = "4.15.0" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, @@ -1871,7 +1891,7 @@ wheels = [ [[package]] name = "typing-inspection" version = "0.4.2" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] @@ -1883,7 +1903,7 @@ wheels = [ [[package]] name = "urllib3" version = "2.6.3" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz", hash = "sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed", size = 435556, upload-time = "2026-01-07T16:24:43.925Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" }, @@ -1892,7 +1912,7 @@ wheels = [ [[package]] name = "uv" version = "0.11.6" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/dd/f3/8aceeab67ea69805293ab290e7ca8cc1b61a064d28b8a35c76d8eba063dd/uv-0.11.6.tar.gz", hash = "sha256:e3b21b7e80024c95ff339fcd147ac6fc3dd98d3613c9d45d3a1f4fd1057f127b", size = 4073298, upload-time = "2026-04-09T12:09:01.738Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/1f/fe/4b61a3d5ad9d02e8a4405026ccd43593d7044598e0fa47d892d4dafe44c9/uv-0.11.6-py3-none-linux_armv6l.whl", hash = "sha256:ada04dcf89ddea5b69d27ac9cdc5ef575a82f90a209a1392e930de504b2321d6", size = 23780079, upload-time = "2026-04-09T12:08:56.609Z" }, @@ -1918,7 +1938,7 @@ wheels = [ [[package]] name = "virtualenv" version = "21.2.1" -source = { registry = "https://pypi.org/simple/" } +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "distlib" }, { name = "filelock" }, From 7efa3047cd45f1a3dd5a14f13bac7840b8250327 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Mon, 15 Jun 2026 22:37:58 -0400 Subject: [PATCH 2/8] add changelog fragment --- .changelog/5252.added | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/5252.added diff --git a/.changelog/5252.added b/.changelog/5252.added new file mode 100644 index 00000000000..d1b41dfb476 --- /dev/null +++ b/.changelog/5252.added @@ -0,0 +1 @@ +`opentelemetry-exporter-otlp-common`: add shared package for common OTLP utilities From 541dfd46f6f983ed1eeb77df39953f0c9b9e1e2f Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Mon, 15 Jun 2026 22:42:32 -0400 Subject: [PATCH 3/8] add typechecking --- .../opentelemetry/exporter/otlp/common/_aggregation.py | 9 +++++---- pyproject.toml | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py index bf60f05d848..ed68678ed1f 100644 --- a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py @@ -66,10 +66,11 @@ def _get_temporality( case _: if temporality_preference != "CUMULATIVE": _logger.warning( - "Unrecognized OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE" - " value found: " - "%s, " - "using CUMULATIVE", + ( + "Invalid value for %s: %s, using cumulative " + "temporality aggregation" + ), + OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, temporality_preference, ) instrument_class_temporality: dict[ diff --git a/pyproject.toml b/pyproject.toml index 95c826e01b6..a273dff32da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,6 +128,7 @@ include = [ "exporter/opentelemetry-exporter-otlp-proto-grpc", "exporter/opentelemetry-exporter-otlp-proto-http", "exporter/opentelemetry-exporter-otlp-json-common", + "exporter/opentelemetry-exporter-otlp-common", "codegen/opentelemetry-codegen-json" ] @@ -147,6 +148,7 @@ exclude = [ "exporter/opentelemetry-exporter-otlp-proto-grpc/tests", "exporter/opentelemetry-exporter-otlp-proto-http/tests", "exporter/opentelemetry-exporter-otlp-json-common/tests", + "exporter/opentelemetry-exporter-otlp-common/tests", "exporter/opentelemetry-exporter-otlp-json-common/benchmarks", ] From 26197c7264c85e6c817573a074b022be6cb1f773 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Mon, 15 Jun 2026 22:52:25 -0400 Subject: [PATCH 4/8] update tox environment names --- .github/workflows/lint.yml | 6 +- .github/workflows/test.yml | 144 ++++++++++++++++++------------------- tox.ini | 14 ++-- 3 files changed, 82 insertions(+), 82 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 457aea69582..f60b638b73b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -214,8 +214,8 @@ jobs: - name: Run tests run: tox -e lint-opentelemetry-exporter-http-transport - lint-opentelemetry-exporter-otlp-common-latest: - name: opentelemetry-exporter-otlp-common-latest + lint-opentelemetry-exporter-otlpcommon-latest: + name: opentelemetry-exporter-otlpcommon-latest runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -231,7 +231,7 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e lint-opentelemetry-exporter-otlp-common-latest + run: tox -e lint-opentelemetry-exporter-otlpcommon-latest lint-opentelemetry-exporter-opencensus: name: opentelemetry-exporter-opencensus diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a5dbadd4c00..3953b1f1ac6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1642,8 +1642,8 @@ jobs: - name: Run tests run: tox -e py314t-test-opentelemetry-exporter-http-transport-latest -- -ra - py310-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.10 Ubuntu + py310-test-opentelemetry-exporter-otlpcommon-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.10 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1659,10 +1659,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py310-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py310-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py310-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-latest 3.10 Ubuntu + py310-test-opentelemetry-exporter-otlpcommon-latest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.10 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1678,10 +1678,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py310-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py310-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py311-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.11 Ubuntu + py311-test-opentelemetry-exporter-otlpcommon-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.11 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1697,10 +1697,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py311-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py311-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py311-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-latest 3.11 Ubuntu + py311-test-opentelemetry-exporter-otlpcommon-latest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.11 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1716,10 +1716,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py311-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py311-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py312-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.12 Ubuntu + py312-test-opentelemetry-exporter-otlpcommon-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.12 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1735,10 +1735,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py312-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py312-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py312-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-latest 3.12 Ubuntu + py312-test-opentelemetry-exporter-otlpcommon-latest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.12 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1754,10 +1754,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py312-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py312-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py313-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.13 Ubuntu + py313-test-opentelemetry-exporter-otlpcommon-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.13 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1773,10 +1773,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py313-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py313-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py313-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-latest 3.13 Ubuntu + py313-test-opentelemetry-exporter-otlpcommon-latest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.13 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1792,10 +1792,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py313-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py313-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py314-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.14 Ubuntu + py314-test-opentelemetry-exporter-otlpcommon-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.14 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1811,10 +1811,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py314-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py314-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-latest 3.14 Ubuntu + py314-test-opentelemetry-exporter-otlpcommon-latest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.14 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1830,10 +1830,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py314-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py314t-test-opentelemetry-exporter-otlp-common-oldest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.14t Ubuntu + py314t-test-opentelemetry-exporter-otlpcommon-oldest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.14t Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1849,10 +1849,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314t-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py314t-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py314t-test-opentelemetry-exporter-otlp-common-latest_ubuntu-latest: - name: opentelemetry-exporter-otlp-common-latest 3.14t Ubuntu + py314t-test-opentelemetry-exporter-otlpcommon-latest_ubuntu-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.14t Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -1868,7 +1868,7 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314t-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py314t-test-opentelemetry-exporter-otlpcommon-latest -- -ra py310-test-opentelemetry-exporter-opencensus_ubuntu-latest: name: opentelemetry-exporter-opencensus 3.10 Ubuntu @@ -5508,8 +5508,8 @@ jobs: - name: Run tests run: tox -e py314t-test-opentelemetry-exporter-http-transport-latest -- -ra - py310-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.10 Windows + py310-test-opentelemetry-exporter-otlpcommon-oldest_windows-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.10 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5527,10 +5527,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py310-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py310-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py310-test-opentelemetry-exporter-otlp-common-latest_windows-latest: - name: opentelemetry-exporter-otlp-common-latest 3.10 Windows + py310-test-opentelemetry-exporter-otlpcommon-latest_windows-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.10 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5548,10 +5548,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py310-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py310-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py311-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.11 Windows + py311-test-opentelemetry-exporter-otlpcommon-oldest_windows-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.11 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5569,10 +5569,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py311-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py311-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py311-test-opentelemetry-exporter-otlp-common-latest_windows-latest: - name: opentelemetry-exporter-otlp-common-latest 3.11 Windows + py311-test-opentelemetry-exporter-otlpcommon-latest_windows-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.11 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5590,10 +5590,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py311-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py311-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py312-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.12 Windows + py312-test-opentelemetry-exporter-otlpcommon-oldest_windows-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.12 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5611,10 +5611,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py312-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py312-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py312-test-opentelemetry-exporter-otlp-common-latest_windows-latest: - name: opentelemetry-exporter-otlp-common-latest 3.12 Windows + py312-test-opentelemetry-exporter-otlpcommon-latest_windows-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.12 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5632,10 +5632,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py312-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py312-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py313-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.13 Windows + py313-test-opentelemetry-exporter-otlpcommon-oldest_windows-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.13 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5653,10 +5653,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py313-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py313-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py313-test-opentelemetry-exporter-otlp-common-latest_windows-latest: - name: opentelemetry-exporter-otlp-common-latest 3.13 Windows + py313-test-opentelemetry-exporter-otlpcommon-latest_windows-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.13 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5674,10 +5674,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py313-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py313-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py314-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.14 Windows + py314-test-opentelemetry-exporter-otlpcommon-oldest_windows-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.14 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5695,10 +5695,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py314-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py314-test-opentelemetry-exporter-otlp-common-latest_windows-latest: - name: opentelemetry-exporter-otlp-common-latest 3.14 Windows + py314-test-opentelemetry-exporter-otlpcommon-latest_windows-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.14 Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5716,10 +5716,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py314-test-opentelemetry-exporter-otlpcommon-latest -- -ra - py314t-test-opentelemetry-exporter-otlp-common-oldest_windows-latest: - name: opentelemetry-exporter-otlp-common-oldest 3.14t Windows + py314t-test-opentelemetry-exporter-otlpcommon-oldest_windows-latest: + name: opentelemetry-exporter-otlpcommon-oldest 3.14t Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5737,10 +5737,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314t-test-opentelemetry-exporter-otlp-common-oldest -- -ra + run: tox -e py314t-test-opentelemetry-exporter-otlpcommon-oldest -- -ra - py314t-test-opentelemetry-exporter-otlp-common-latest_windows-latest: - name: opentelemetry-exporter-otlp-common-latest 3.14t Windows + py314t-test-opentelemetry-exporter-otlpcommon-latest_windows-latest: + name: opentelemetry-exporter-otlpcommon-latest 3.14t Windows runs-on: windows-latest timeout-minutes: 30 steps: @@ -5758,7 +5758,7 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py314t-test-opentelemetry-exporter-otlp-common-latest -- -ra + run: tox -e py314t-test-opentelemetry-exporter-otlpcommon-latest -- -ra py310-test-opentelemetry-exporter-opencensus_windows-latest: name: opentelemetry-exporter-opencensus 3.10 Windows diff --git a/tox.ini b/tox.ini index 8dfbf96b39b..1acd90d9764 100644 --- a/tox.ini +++ b/tox.ini @@ -48,9 +48,9 @@ envlist = ; exporter-http-transport intentionally excluded from pypy3 lint-opentelemetry-exporter-http-transport - py3{10,11,12,13,14,14t}-test-opentelemetry-exporter-otlp-common-{oldest,latest} - ; exporter-otlp-common intentionally excluded from pypy3 - lint-opentelemetry-exporter-otlp-common-latest + py3{10,11,12,13,14,14t}-test-opentelemetry-exporter-otlpcommon-{oldest,latest} + ; exporter-otlpcommon intentionally excluded from pypy3 + lint-opentelemetry-exporter-otlpcommon-latest py3{10,11,12,13,14}-test-opentelemetry-exporter-opencensus ; exporter-opencensus intentionally excluded from pypy3 @@ -151,8 +151,8 @@ deps = opentelemetry-exporter-http-transport-oldest: -r {toxinidir}/exporter/opentelemetry-exporter-http-transport/test-requirements.oldest.txt opentelemetry-exporter-http-transport-latest: -r {toxinidir}/exporter/opentelemetry-exporter-http-transport/test-requirements.latest.txt - opentelemetry-exporter-otlp-common-oldest: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt - opentelemetry-exporter-otlp-common-latest: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt + opentelemetry-exporter-otlpcommon-oldest: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-common/test-requirements.oldest.txt + opentelemetry-exporter-otlpcommon-latest: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-common/test-requirements.latest.txt exporter-opencensus: -r {toxinidir}/exporter/opentelemetry-exporter-opencensus/test-requirements.txt @@ -253,8 +253,8 @@ commands = test-opentelemetry-exporter-http-transport: pytest {toxinidir}/exporter/opentelemetry-exporter-http-transport/tests {posargs} lint-opentelemetry-exporter-http-transport: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-http-transport" - test-opentelemetry-exporter-otlp-common: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-common/tests {posargs} - lint-opentelemetry-exporter-otlp-common: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp-common" + test-opentelemetry-exporter-otlpcommon: pytest {toxinidir}/exporter/opentelemetry-exporter-otlp-common/tests {posargs} + lint-opentelemetry-exporter-otlpcommon: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-otlp-common" test-opentelemetry-exporter-opencensus: pytest {toxinidir}/exporter/opentelemetry-exporter-opencensus/tests {posargs} lint-opentelemetry-exporter-opencensus: sh -c "cd exporter && pylint --rcfile ../.pylintrc {toxinidir}/exporter/opentelemetry-exporter-opencensus" From 9dd0f246722d34f1e33184bf64444686c805c279 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Mon, 15 Jun 2026 23:13:38 -0400 Subject: [PATCH 5/8] fix missing content-encoding header --- .../README.rst | 33 ++----------------- .../exporter/otlp/common/_http.py | 5 ++- .../tests/test_http_client.py | 24 +++++++------- 3 files changed, 18 insertions(+), 44 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-common/README.rst b/exporter/opentelemetry-exporter-otlp-common/README.rst index 5db31d7a229..c28b5fb7d1e 100644 --- a/exporter/opentelemetry-exporter-otlp-common/README.rst +++ b/exporter/opentelemetry-exporter-otlp-common/README.rst @@ -1,4 +1,4 @@ -OpenTelemetry OTLP HTTP Common +OpenTelemetry OTLP Utilities =============================== |pypi| @@ -6,10 +6,10 @@ OpenTelemetry OTLP HTTP Common .. |pypi| image:: https://badge.fury.io/py/opentelemetry-exporter-otlp-common.svg :target: https://pypi.org/project/opentelemetry-exporter-otlp-common/ -OpenTelemetry OTLP HTTP export utilities. +OpenTelemetry OTLP export utilities. This package is intended to be used by OpenTelemetry signal exporters (traces, metrics, -logs) that send telemetry over OTLP/HTTP. Currently, all functionality in this package +logs) that send telemetry with OTLP. Currently, all functionality in this package is marked as internal and is not intended for use directly by application developers. Installation @@ -19,35 +19,8 @@ Installation pip install opentelemetry-exporter-otlp-common -Usage ------ - -``OTLPHTTPClient`` wraps a transport and handles retry and compression. Pass it a -transport and an endpoint, then call ``export()`` with a serialized OTLP payload:: - - from opentelemetry.exporter.http.transport._requests import RequestsHTTPTransport - from opentelemetry.exporter.otlp.http.common._otlp_client import ( - Compression, - OTLPHTTPClient, - ) - - transport = RequestsHTTPTransport() - client = OTLPHTTPClient( - transport=transport, - endpoint="http://localhost:4318/v1/traces", - kind="spans", - compression=Compression.GZIP, - ) - - result = client.export(serialized_bytes) - if not result.success: - print(f"Export failed: {result.status_code} {result.reason}") - - client.close() - References ---------- * `OpenTelemetry `_ * `OTLP Specification `_ -* `opentelemetry-exporter-http-transport `_ diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py index fa8303ae56e..d7a9d36ab8c 100644 --- a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py @@ -17,7 +17,6 @@ from typing import TYPE_CHECKING, Final, Literal if TYPE_CHECKING: - # pylint: disable-next=import-error from opentelemetry.exporter.http.transport._base import ( BaseHTTPResult, BaseHTTPTransport, @@ -113,6 +112,10 @@ def __init__( shutdown_event if shutdown_event is not None else threading.Event() ) self._headers = dict(headers) if headers is not None else {} + if self._compression is not Compression.NONE and not any( + key.lower() == "content-encoding" for key in self._headers + ): + self._headers["Content-Encoding"] = self._compression.value self._kind = kind self._jitter = min(max(jitter, 0.0), 1.0) self._logger = logger if logger is not None else _logger diff --git a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py index a549423f05d..2c84b86d4dd 100644 --- a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py +++ b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py @@ -172,21 +172,12 @@ def test_export_request_arguments(self, mock_time): def test_export_compresses_payload(self): cases = ( - ( - Compression.NONE, - lambda data: data, - ), - ( - Compression.GZIP, - gzip.decompress, - ), - ( - Compression.DEFLATE, - zlib.decompress, - ), + (Compression.NONE, lambda data: data, None), + (Compression.GZIP, gzip.decompress, "gzip"), + (Compression.DEFLATE, zlib.decompress, "deflate"), ) - for compression, decompress in cases: + for compression, decompress, expected_encoding in cases: with self.subTest(compression=compression): transport = _TestHTTPTransport( _TestHTTPResult(status_code=200, reason="OK") @@ -199,6 +190,13 @@ def test_export_compresses_payload(self): self.assertEqual( decompress(transport.requests[0]["data"]), b"payload" ) + headers = transport.requests[0]["headers"] + if expected_encoding is None: + self.assertNotIn("Content-Encoding", headers) + else: + self.assertEqual( + headers["Content-Encoding"], expected_encoding + ) def test_export_retryable_status_codes(self): cases = ( From f60a90058464c17e06d17f7d537631d98bfe25ca Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Tue, 16 Jun 2026 00:03:43 -0400 Subject: [PATCH 6/8] fix docs build failures --- .../opentelemetry/exporter/otlp/json/file/_log_exporter.py | 6 +++--- .../exporter/otlp/json/file/metric_exporter.py | 6 +++--- .../opentelemetry/exporter/otlp/json/file/trace_exporter.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/_log_exporter.py b/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/_log_exporter.py index 6fd1110e8f3..46e2b01bf4f 100644 --- a/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/_log_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/_log_exporter.py @@ -2,8 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 import logging +import os from collections.abc import Sequence -from os import PathLike from typing import IO, Any, overload from opentelemetry.exporter.otlp.json.common._log_encoder import encode_logs @@ -30,7 +30,7 @@ class FileLogExporter(LogRecordExporter): @overload def __init__( self, - path: str | PathLike[str], + path: str | os.PathLike[str], ) -> None: ... @overload @@ -47,7 +47,7 @@ def __init__( def __init__( self, - path: str | PathLike[str] | None = None, + path: str | os.PathLike[str] | None = None, *, stream: IO[str] | None = None, ) -> None: diff --git a/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/metric_exporter.py b/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/metric_exporter.py index 93d0dbb14b2..e0183566ad3 100644 --- a/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/metric_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/metric_exporter.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 import logging -from os import PathLike +import os from typing import IO, Any, overload from opentelemetry.exporter.otlp.json.common._internal import ( @@ -35,7 +35,7 @@ class FileMetricExporter(MetricExporter): @overload def __init__( self, - path: str | PathLike[str], + path: str | os.PathLike[str], *, preferred_temporality: dict[type, AggregationTemporality] | None = None, @@ -63,7 +63,7 @@ def __init__( def __init__( self, - path: str | PathLike[str] | None = None, + path: str | os.PathLike[str] | None = None, *, stream: IO[str] | None = None, preferred_temporality: dict[type, AggregationTemporality] diff --git a/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/trace_exporter.py b/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/trace_exporter.py index 726307eb428..3609e46fcc0 100644 --- a/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/trace_exporter.py +++ b/exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/trace_exporter.py @@ -2,8 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 import logging +import os from collections.abc import Sequence -from os import PathLike from typing import IO, Any, overload from opentelemetry.exporter.otlp.json.common.trace_encoder import encode_spans @@ -25,7 +25,7 @@ class FileSpanExporter(SpanExporter): @overload def __init__( self, - path: str | PathLike[str], + path: str | os.PathLike[str], ) -> None: ... @overload @@ -42,7 +42,7 @@ def __init__( def __init__( self, - path: str | PathLike[str] | None = None, + path: str | os.PathLike[str] | None = None, *, stream: IO[str] | None = None, ) -> None: From 38dab2e305224a3418a7976a6a631c30a8a4c11f Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Thu, 25 Jun 2026 17:58:37 -0500 Subject: [PATCH 7/8] add shutdown() method and remove close() method and remove shutdown_event from client ctor --- .../pyproject.toml | 4 +- .../exporter/otlp/common/_aggregation.py | 24 ++++----- .../exporter/otlp/common/_http.py | 15 +++--- .../exporter/otlp/common/version/__init__.py | 2 +- .../tests/test_http_client.py | 50 +++++++++---------- 5 files changed, 44 insertions(+), 51 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-common/pyproject.toml b/exporter/opentelemetry-exporter-otlp-common/pyproject.toml index e849871c234..70413faa1c8 100644 --- a/exporter/opentelemetry-exporter-otlp-common/pyproject.toml +++ b/exporter/opentelemetry-exporter-otlp-common/pyproject.toml @@ -26,12 +26,12 @@ classifiers = [ "Programming Language :: Python :: 3.14", ] dependencies = [ - "opentelemetry-sdk ~= 1.43.0.dev", + "opentelemetry-sdk ~= 1.44.0.dev", ] [project.optional-dependencies] http = [ - "opentelemetry-exporter-http-transport == 0.64b0.dev", + "opentelemetry-exporter-http-transport == 0.65b0.dev", ] [project.urls] diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py index ed68678ed1f..93259d1d116 100644 --- a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_aggregation.py @@ -40,11 +40,10 @@ def _get_temporality( .strip() ) + instrument_class_temporality: dict[type, AggregationTemporality] match temporality_preference: case "DELTA": - instrument_class_temporality: dict[ - type, AggregationTemporality - ] = { + instrument_class_temporality = { Counter: AggregationTemporality.DELTA, UpDownCounter: AggregationTemporality.CUMULATIVE, Histogram: AggregationTemporality.DELTA, @@ -53,9 +52,7 @@ def _get_temporality( ObservableGauge: AggregationTemporality.CUMULATIVE, } case "LOWMEMORY": - instrument_class_temporality: dict[ - type, AggregationTemporality - ] = { + instrument_class_temporality = { Counter: AggregationTemporality.DELTA, UpDownCounter: AggregationTemporality.CUMULATIVE, Histogram: AggregationTemporality.DELTA, @@ -73,9 +70,7 @@ def _get_temporality( OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, temporality_preference, ) - instrument_class_temporality: dict[ - type, AggregationTemporality - ] = { + instrument_class_temporality = { Counter: AggregationTemporality.CUMULATIVE, UpDownCounter: AggregationTemporality.CUMULATIVE, Histogram: AggregationTemporality.CUMULATIVE, @@ -84,8 +79,7 @@ def _get_temporality( ObservableGauge: AggregationTemporality.CUMULATIVE, } - instrument_class_temporality.update(preferred_temporality or {}) - return instrument_class_temporality + return instrument_class_temporality | (preferred_temporality or {}) def _get_aggregation( @@ -100,9 +94,10 @@ def _get_aggregation( .strip() ) + instrument_class_aggregation: dict[type, Aggregation] match default_histogram_aggregation: case "BASE2_EXPONENTIAL_BUCKET_HISTOGRAM": - instrument_class_aggregation: dict[type, Aggregation] = { + instrument_class_aggregation = { Histogram: ExponentialBucketHistogramAggregation(), } case _: @@ -116,9 +111,8 @@ def _get_aggregation( default_histogram_aggregation, ) - instrument_class_aggregation: dict[type, Aggregation] = { + instrument_class_aggregation = { Histogram: ExplicitBucketHistogramAggregation(), } - instrument_class_aggregation.update(preferred_aggregation or {}) - return instrument_class_aggregation + return instrument_class_aggregation | (preferred_aggregation or {}) diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py index d7a9d36ab8c..7d3b56df8fc 100644 --- a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py @@ -99,7 +99,6 @@ def __init__( kind: Literal["spans", "logs", "metrics"], timeout: float = _DEFAULT_TIMEOUT, compression: Compression = Compression.NONE, - shutdown_event: threading.Event | None = None, headers: Mapping[str, str] | None = None, jitter: float = _DEFAULT_JITTER, logger: logging.Logger | None = None, @@ -108,9 +107,6 @@ def __init__( self._endpoint = endpoint self._timeout = timeout self._compression = compression - self._shutdown_event = ( - shutdown_event if shutdown_event is not None else threading.Event() - ) self._headers = dict(headers) if headers is not None else {} if self._compression is not Compression.NONE and not any( key.lower() == "content-encoding" for key in self._headers @@ -119,6 +115,8 @@ def __init__( self._kind = kind self._jitter = min(max(jitter, 0.0), 1.0) self._logger = logger if logger is not None else _logger + self._shutdown = False + self._shutdown_event = threading.Event() def _compute_backoff(self, retry: int) -> float: return 2**retry * random.uniform(1 - self._jitter, 1 + self._jitter) @@ -234,6 +232,11 @@ def export(self, data: bytes) -> ExportResult: return ExportResult(False, None, None, None) - def close(self) -> None: - """Close the underlying transport and release its resources.""" + def shutdown(self) -> None: + """Shutdown the client.""" + if self._shutdown: + self._logger.warning("OTLP client already shutdown, ignoring call") + return + self._shutdown = True + self._shutdown_event.set() self._transport.close() diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py index 13e069be44f..357a2a12e6b 100644 --- a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/version/__init__.py @@ -1,4 +1,4 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -__version__ = "0.64b0.dev" +__version__ = "0.65b0.dev" diff --git a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py index 2c84b86d4dd..e038e088ffe 100644 --- a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py +++ b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py @@ -110,7 +110,6 @@ def _client( *, timeout=5.0, compression=Compression.NONE, - shutdown_event=None, jitter=0.0, ): return OTLPHTTPClient( @@ -118,7 +117,6 @@ def _client( endpoint="http://example.test/v1/traces", timeout=timeout, compression=compression, - shutdown_event=shutdown_event or threading.Event(), headers={"content-type": "application/x-protobuf"}, kind="spans", jitter=jitter, @@ -218,10 +216,9 @@ def test_export_retryable_status_codes(self): ), _TestHTTPResult(status_code=200, reason="OK"), ) - client = self._client( - transport, - shutdown_event=shutdown_event, - ) + client = self._client(transport) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event result = client.export(b"payload") @@ -309,7 +306,9 @@ def test_export_with_shutdown(self): transport = _TestHTTPTransport( _TestHTTPResult(status_code=503, reason="Service Unavailable") ) - client = self._client(transport, shutdown_event=shutdown_event) + client = self._client(transport) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event result = client.export(b"payload") @@ -318,11 +317,11 @@ def test_export_with_shutdown(self): self.assertEqual(result.reason, "Service Unavailable") shutdown_event.wait.assert_not_called() - def test_close_closes_transport(self): + def test_shutdown_closes_transport(self): transport = _TestHTTPTransport() client = self._client(transport) - client.close() + client.shutdown() self.assertTrue(transport.closed) @@ -334,9 +333,9 @@ def test_export_timeout_decreases_per_retry(self): _TestHTTPResult(status_code=503, reason="Service Unavailable"), _TestHTTPResult(status_code=200, reason="OK"), ) - client = self._client( - transport, timeout=10.0, jitter=0.0, shutdown_event=shutdown_event - ) + client = self._client(transport, timeout=10.0, jitter=0.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event with _mock_clock(shutdown_event): result = client.export(b"payload") @@ -356,9 +355,9 @@ def test_export_backoff_exhausts_remaining_timeout(self): ) # timeout=1.5: retry=0 backoff=1.0 fits -> wait(1.0) -> time=1.0 # retry=1 backoff=2.0 > 0.5 remaining -> give up - client = self._client( - transport, timeout=1.5, jitter=0.0, shutdown_event=shutdown_event - ) + client = self._client(transport, timeout=1.5, jitter=0.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event with _mock_clock(shutdown_event): result = client.export(b"payload") @@ -375,12 +374,9 @@ def test_export_exhausts_max_retries(self): *[_TestHTTPResult(status_code=503, reason="Service Unavailable")] * 6 ) - client = self._client( - transport, - timeout=1000.0, - jitter=0.0, - shutdown_event=shutdown_event, - ) + client = self._client(transport, timeout=1000.0, jitter=0.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event with _mock_clock(shutdown_event): result = client.export(b"payload") @@ -427,9 +423,9 @@ def test_export_retry_after_header_used_as_backoff(self): ), _TestHTTPResult(status_code=200, reason="OK"), ) - client = self._client( - transport, timeout=60.0, shutdown_event=shutdown_event - ) + client = self._client(transport, timeout=60.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event result = client.export(b"payload") @@ -447,9 +443,9 @@ def test_export_retry_after_header_exhausts_timeout(self): response_headers={"retry-after": "10"}, ), ) - client = self._client( - transport, timeout=3.0, jitter=0.0, shutdown_event=shutdown_event - ) + client = self._client(transport, timeout=3.0, jitter=0.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event with _mock_clock(shutdown_event): result = client.export(b"payload") From 7537a5635ed2224d6ae2a2606aaa8fc2982bf6b7 Mon Sep 17 00:00:00 2001 From: Lukas Hering Date: Sat, 27 Jun 2026 00:07:11 -0500 Subject: [PATCH 8/8] update retry-after parsing --- .../exporter/otlp/common/_http.py | 27 ++++- .../tests/test_http_client.py | 109 ++++++++++++++++++ 2 files changed, 133 insertions(+), 3 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py index 7d3b56df8fc..3680be73ba6 100644 --- a/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py +++ b/exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/_http.py @@ -6,12 +6,15 @@ import enum import gzip import logging +import math import random import threading import time import zlib from collections.abc import Mapping from dataclasses import dataclass +from datetime import timezone +from email.utils import parsedate_to_datetime from http import HTTPStatus from io import BytesIO from typing import TYPE_CHECKING, Final, Literal @@ -44,14 +47,32 @@ def _is_retryable(status_code: int | None) -> bool: def _extract_retry_after(result: BaseHTTPResult) -> float | None: + """Parse the ``Retry-After`` header (RFC 7231).""" try: value = result.headers().get("retry-after") - if value is not None: - return float(value) # pylint: disable-next=broad-exception-caught except Exception: + return None + if value is None: + return None + value = value.strip() + + # delay-seconds: a non-negative decimal integer. + try: + seconds = float(value) + except ValueError: pass - return None + else: + return max(seconds, 0.0) if math.isfinite(seconds) else None + + # HTTP-date: wait until the indicated absolute time. + try: + retry_at = parsedate_to_datetime(value) + except (TypeError, ValueError): + return None + if retry_at.tzinfo is None: + retry_at = retry_at.replace(tzinfo=timezone.utc) + return max(retry_at.timestamp() - time.time(), 0.0) class Compression(enum.Enum): diff --git a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py index e038e088ffe..e7a7e420da5 100644 --- a/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py +++ b/exporter/opentelemetry-exporter-otlp-common/tests/test_http_client.py @@ -10,6 +10,8 @@ from collections.abc import Callable, Iterator from contextlib import contextmanager from dataclasses import dataclass, field +from datetime import datetime, timezone +from email.utils import format_datetime from unittest.mock import Mock, patch # pylint: disable-next=import-error @@ -22,6 +24,7 @@ from opentelemetry.exporter.otlp.common._http import ( Compression, OTLPHTTPClient, + _extract_retry_after, ) @@ -454,3 +457,109 @@ def test_export_retry_after_header_exhausts_timeout(self): self.assertEqual(result.status_code, 503) self.assertEqual(len(transport.requests), 1) shutdown_event.wait.assert_not_called() + + def test_export_retry_after_http_date(self): + base = 1_700_000_000.0 + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + shutdown_event.wait.return_value = False + retry_at = format_datetime( + datetime.fromtimestamp(base + 30, timezone.utc), usegmt=True + ) + transport = _TestHTTPTransport( + _TestHTTPResult( + status_code=503, + reason="Service Unavailable", + response_headers={"retry-after": retry_at}, + ), + _TestHTTPResult(status_code=200, reason="OK"), + ) + client = self._client(transport, timeout=120.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event + + with patch( + "opentelemetry.exporter.otlp.common._http.time.time", + return_value=base, + ): + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + shutdown_event.wait.assert_called_once_with(30.0) + + def test_export_retry_after_http_date_in_past(self): + base = 1_700_000_000.0 + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + shutdown_event.wait.return_value = False + retry_at = format_datetime( + datetime.fromtimestamp(base - 30, timezone.utc), usegmt=True + ) + transport = _TestHTTPTransport( + _TestHTTPResult( + status_code=429, + reason="Too Many Requests", + response_headers={"retry-after": retry_at}, + ), + _TestHTTPResult(status_code=200, reason="OK"), + ) + client = self._client(transport, timeout=120.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event + + with patch( + "opentelemetry.exporter.otlp.common._http.time.time", + return_value=base, + ): + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + shutdown_event.wait.assert_called_once_with(0.0) + + def test_export_retry_after_malformed(self): + shutdown_event = Mock(spec=threading.Event) + shutdown_event.is_set.return_value = False + shutdown_event.wait.return_value = False + transport = _TestHTTPTransport( + _TestHTTPResult( + status_code=503, + reason="Service Unavailable", + response_headers={"retry-after": "not-a-date"}, + ), + _TestHTTPResult(status_code=200, reason="OK"), + ) + client = self._client(transport, timeout=60.0, jitter=0.0) + # pylint: disable-next=protected-access + client._shutdown_event = shutdown_event + + result = client.export(b"payload") + + self.assertTrue(result.success) + self.assertEqual(len(transport.requests), 2) + # No usable Retry-After -> exponential backoff: 2**0 * uniform(1, 1). + shutdown_event.wait.assert_called_once_with(1.0) + + def test_extract_retry_after_edge_cases(self): + cases = ( + ("5", 5.0), + (" 7 ", 7.0), + ("-3", 0.0), + ("nan", None), + ("inf", None), + ("garbage", None), + ) + for value, expected in cases: + with self.subTest(value=value): + self.assertEqual( + _extract_retry_after( + _TestHTTPResult( + response_headers={"retry-after": value} + ) + ), + expected, + ) + + with self.subTest(value="absent"): + self.assertIsNone(_extract_retry_after(_TestHTTPResult()))