diff --git a/.github/workflows/core_contrib_test_0.yml b/.github/workflows/core_contrib_test_0.yml index c8c8b474a7..fce687457e 100644 --- a/.github/workflows/core_contrib_test_0.yml +++ b/.github/workflows/core_contrib_test_0.yml @@ -158,8 +158,8 @@ jobs: - name: Run tests run: tox -e py39-test-instrumentation-google-genai-latest -- -ra - py39-test-resource-detector-container: - name: resource-detector-container + py39-test-resource-detector-containerid: + name: resource-detector-containerid runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -179,7 +179,7 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py39-test-resource-detector-container -- -ra + run: tox -e py39-test-resource-detector-containerid -- -ra py39-test-resource-detector-azure-0: name: resource-detector-azure-0 diff --git a/.github/workflows/lint_0.yml b/.github/workflows/lint_0.yml index 630a25c816..406e1aecb0 100644 --- a/.github/workflows/lint_0.yml +++ b/.github/workflows/lint_0.yml @@ -85,8 +85,8 @@ jobs: - name: Run tests run: tox -e lint-instrumentation-google-genai - lint-resource-detector-container: - name: resource-detector-container + lint-resource-detector-containerid: + name: resource-detector-containerid runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -102,7 +102,7 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e lint-resource-detector-container + run: tox -e lint-resource-detector-containerid lint-resource-detector-azure: name: resource-detector-azure diff --git a/.github/workflows/test_0.yml b/.github/workflows/test_0.yml index 06da51a55c..643cccfd5c 100644 --- a/.github/workflows/test_0.yml +++ b/.github/workflows/test_0.yml @@ -636,8 +636,8 @@ jobs: - name: Run tests run: tox -e py313-test-instrumentation-google-genai-latest -- -ra - py39-test-resource-detector-container_ubuntu-latest: - name: resource-detector-container 3.9 Ubuntu + py39-test-resource-detector-containerid_ubuntu-latest: + name: resource-detector-containerid 3.9 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -653,10 +653,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py39-test-resource-detector-container -- -ra + run: tox -e py39-test-resource-detector-containerid -- -ra - py310-test-resource-detector-container_ubuntu-latest: - name: resource-detector-container 3.10 Ubuntu + py310-test-resource-detector-containerid_ubuntu-latest: + name: resource-detector-containerid 3.10 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -672,10 +672,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py310-test-resource-detector-container -- -ra + run: tox -e py310-test-resource-detector-containerid -- -ra - py311-test-resource-detector-container_ubuntu-latest: - name: resource-detector-container 3.11 Ubuntu + py311-test-resource-detector-containerid_ubuntu-latest: + name: resource-detector-containerid 3.11 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -691,10 +691,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py311-test-resource-detector-container -- -ra + run: tox -e py311-test-resource-detector-containerid -- -ra - py312-test-resource-detector-container_ubuntu-latest: - name: resource-detector-container 3.12 Ubuntu + py312-test-resource-detector-containerid_ubuntu-latest: + name: resource-detector-containerid 3.12 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -710,10 +710,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py312-test-resource-detector-container -- -ra + run: tox -e py312-test-resource-detector-containerid -- -ra - py313-test-resource-detector-container_ubuntu-latest: - name: resource-detector-container 3.13 Ubuntu + py313-test-resource-detector-containerid_ubuntu-latest: + name: resource-detector-containerid 3.13 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -729,10 +729,10 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e py313-test-resource-detector-container -- -ra + run: tox -e py313-test-resource-detector-containerid -- -ra - pypy3-test-resource-detector-container_ubuntu-latest: - name: resource-detector-container pypy-3.9 Ubuntu + pypy3-test-resource-detector-containerid_ubuntu-latest: + name: resource-detector-containerid pypy-3.9 Ubuntu runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -748,7 +748,7 @@ jobs: run: pip install tox-uv - name: Run tests - run: tox -e pypy3-test-resource-detector-container -- -ra + run: tox -e pypy3-test-resource-detector-containerid -- -ra py39-test-resource-detector-azure-0_ubuntu-latest: name: resource-detector-azure-0 3.9 Ubuntu diff --git a/CHANGELOG.md b/CHANGELOG.md index 9be7b9b60b..26962b4eee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,11 +60,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3474](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3474)) - `opentelemetry-instrumentation-fastapi`: Drop support for FastAPI versions earlier than `0.92` ([#3012](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3012)) +- `opentelemetry-resource-detector-container`: rename package name to `opentelemetry-resource-detector-containerid` + ([#3536](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3536)) ### Added - `opentelemetry-instrumentation-aiohttp-client` Add support for HTTP metrics - ([#3517](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3517)) + ([#3517](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3517)) - `opentelemetry-instrumentation-httpx` Add support for HTTP metrics ([#3513](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3513)) diff --git a/docs/index.rst b/docs/index.rst index f9144c5209..11c611685b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -52,7 +52,7 @@ install pip install -e ./instrumentation/opentelemetry-instrumentation-botocore pip install -e ./instrumentation-genai/opentelemetry-instrumentation-openai-v2 pip install -e ./sdk-extension/opentelemetry-sdk-extension-aws - pip install -e ./resource/opentelemetry-resource-detector-container + pip install -e ./resource/opentelemetry-resource-detector-containerid .. toctree:: diff --git a/docs/resource/container/container.rst b/docs/resource/container/container.rst index e69a2f6a0f..ff71483d5a 100644 --- a/docs/resource/container/container.rst +++ b/docs/resource/container/container.rst @@ -1,7 +1,7 @@ OpenTelemetry Python - Resource Detector for Containers ======================================================= -.. automodule:: opentelemetry.resource.detector.container +.. automodule:: opentelemetry.resource.detector.containerid :members: :undoc-members: :show-inheritance: diff --git a/eachdist.ini b/eachdist.ini index 863ca33429..2d964b6b29 100644 --- a/eachdist.ini +++ b/eachdist.ini @@ -43,7 +43,7 @@ packages= opentelemetry-instrumentation opentelemetry-contrib-instrumentations opentelemetry-distro - opentelemetry-resource-detector-container + opentelemetry-resource-detector-containerid [exclude_release] packages= diff --git a/resource/opentelemetry-resource-detector-container/LICENSE b/resource/opentelemetry-resource-detector-containerid/LICENSE similarity index 100% rename from resource/opentelemetry-resource-detector-container/LICENSE rename to resource/opentelemetry-resource-detector-containerid/LICENSE diff --git a/resource/opentelemetry-resource-detector-container/MANIFEST.rst b/resource/opentelemetry-resource-detector-containerid/MANIFEST.rst similarity index 100% rename from resource/opentelemetry-resource-detector-container/MANIFEST.rst rename to resource/opentelemetry-resource-detector-containerid/MANIFEST.rst diff --git a/resource/opentelemetry-resource-detector-container/README.rst b/resource/opentelemetry-resource-detector-containerid/README.rst similarity index 81% rename from resource/opentelemetry-resource-detector-container/README.rst rename to resource/opentelemetry-resource-detector-containerid/README.rst index 8fadd67951..b7f452cb4b 100644 --- a/resource/opentelemetry-resource-detector-container/README.rst +++ b/resource/opentelemetry-resource-detector-containerid/README.rst @@ -14,17 +14,17 @@ Installation :: - pip install opentelemetry-resource-detector-container + pip install opentelemetry-resource-detector-containerid --------------------------- -Usage example for `opentelemetry-resource-detector-container` +Usage example for `opentelemetry-resource-detector-containerid` .. code-block:: python from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider - from opentelemetry.resource.detector.container import ( + from opentelemetry.resource.detector.containerid import ( ContainerResourceDetector, ) from opentelemetry.sdk.resources import get_aggregated_resources diff --git a/resource/opentelemetry-resource-detector-container/pyproject.toml b/resource/opentelemetry-resource-detector-containerid/pyproject.toml similarity index 85% rename from resource/opentelemetry-resource-detector-container/pyproject.toml rename to resource/opentelemetry-resource-detector-containerid/pyproject.toml index 6807fa611e..b1003574c2 100644 --- a/resource/opentelemetry-resource-detector-container/pyproject.toml +++ b/resource/opentelemetry-resource-detector-containerid/pyproject.toml @@ -3,7 +3,7 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -name = "opentelemetry-resource-detector-container" +name = "opentelemetry-resource-detector-containerid" dynamic = ["version"] description = "Container Resource Detector for OpenTelemetry" readme = "README.rst" @@ -29,14 +29,14 @@ dependencies = [ ] [project.entry-points.opentelemetry_resource_detector] -container = "opentelemetry.resource.detector.container:ContainerResourceDetector" +containerid = "opentelemetry.resource.detector.containerid:ContainerResourceDetector" [project.urls] -Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/resource/opentelemetry-resource-detector-container" +Homepage = "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/resource/opentelemetry-resource-detector-containerid" Repository = "https://github.com/open-telemetry/opentelemetry-python-contrib" [tool.hatch.version] -path = "src/opentelemetry/resource/detector/container/version.py" +path = "src/opentelemetry/resource/detector/containerid/version.py" [tool.hatch.build.targets.sdist] include = [ diff --git a/resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/__init__.py b/resource/opentelemetry-resource-detector-containerid/src/opentelemetry/resource/detector/containerid/__init__.py similarity index 100% rename from resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/__init__.py rename to resource/opentelemetry-resource-detector-containerid/src/opentelemetry/resource/detector/containerid/__init__.py diff --git a/resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/version.py b/resource/opentelemetry-resource-detector-containerid/src/opentelemetry/resource/detector/containerid/version.py similarity index 100% rename from resource/opentelemetry-resource-detector-container/src/opentelemetry/resource/detector/container/version.py rename to resource/opentelemetry-resource-detector-containerid/src/opentelemetry/resource/detector/containerid/version.py diff --git a/resource/opentelemetry-resource-detector-container/test-requirements.txt b/resource/opentelemetry-resource-detector-containerid/test-requirements.txt similarity index 76% rename from resource/opentelemetry-resource-detector-container/test-requirements.txt rename to resource/opentelemetry-resource-detector-containerid/test-requirements.txt index 859005d42b..fbad04cd33 100644 --- a/resource/opentelemetry-resource-detector-container/test-requirements.txt +++ b/resource/opentelemetry-resource-detector-containerid/test-requirements.txt @@ -9,4 +9,4 @@ tomli==2.0.1 typing_extensions==4.12.2 wrapt==1.16.0 zipp==3.19.2 --e resource/opentelemetry-resource-detector-container +-e resource/opentelemetry-resource-detector-containerid diff --git a/resource/opentelemetry-resource-detector-container/tests/__init__.py b/resource/opentelemetry-resource-detector-containerid/tests/__init__.py similarity index 100% rename from resource/opentelemetry-resource-detector-container/tests/__init__.py rename to resource/opentelemetry-resource-detector-containerid/tests/__init__.py diff --git a/resource/opentelemetry-resource-detector-container/tests/test_container.py b/resource/opentelemetry-resource-detector-containerid/tests/test_container.py similarity index 90% rename from resource/opentelemetry-resource-detector-container/tests/test_container.py rename to resource/opentelemetry-resource-detector-containerid/tests/test_container.py index ae831ee50e..c79fd2ecb0 100644 --- a/resource/opentelemetry-resource-detector-container/tests/test_container.py +++ b/resource/opentelemetry-resource-detector-containerid/tests/test_container.py @@ -15,10 +15,13 @@ from unittest.mock import mock_open, patch from opentelemetry import trace as trace_api -from opentelemetry.resource.detector.container import ContainerResourceDetector +from opentelemetry.resource.detector.containerid import ( + ContainerResourceDetector, +) from opentelemetry.sdk.resources import get_aggregated_resources from opentelemetry.semconv.resource import ResourceAttributes from opentelemetry.test.test_base import TestBase +from opentelemetry.util._importlib_metadata import entry_points MockContainerResourceAttributes = { ResourceAttributes.CONTAINER_ID: "7be92808767a667f35c8505cbf40d14e931ef6db5b0210329cf193b15ba9d605", @@ -66,7 +69,7 @@ def test_container_id_detect_from_cgroup_file_with_suffix( ) @patch( - "opentelemetry.resource.detector.container._get_container_id_v1", + "opentelemetry.resource.detector.containerid._get_container_id_v1", return_value=None, ) @patch( @@ -107,7 +110,7 @@ def test_container_id_detect_from_mountinfo_file( ) @patch( - "opentelemetry.resource.detector.container._get_container_id", + "opentelemetry.resource.detector.containerid._get_container_id", return_value=MockContainerResourceAttributes[ ResourceAttributes.CONTAINER_ID ], @@ -130,7 +133,7 @@ def test_container_id_as_span_attribute(self, mock_cgroup_file): ) @patch( - "opentelemetry.resource.detector.container._get_container_id", + "opentelemetry.resource.detector.containerid._get_container_id", return_value=MockContainerResourceAttributes[ ResourceAttributes.CONTAINER_ID ], @@ -142,11 +145,11 @@ def test_container_id_detect_from_cgroup(self, mock_get_container_id): ) @patch( - "opentelemetry.resource.detector.container._get_container_id_v1", + "opentelemetry.resource.detector.containerid._get_container_id_v1", return_value=None, ) @patch( - "opentelemetry.resource.detector.container._get_container_id_v2", + "opentelemetry.resource.detector.containerid._get_container_id_v2", return_value=MockContainerResourceAttributes[ ResourceAttributes.CONTAINER_ID ], @@ -158,3 +161,10 @@ def test_container_id_detect_from_mount_info( self.assertDictEqual( actual.attributes.copy(), MockContainerResourceAttributes ) + + def test_container_id_entrypoint(self): + (entrypoint,) = entry_points( + group="opentelemetry_resource_detector", name="containerid" + ) + detector = entrypoint.load()() + self.assertIsInstance(detector, ContainerResourceDetector) diff --git a/scripts/build.sh b/scripts/build.sh index 69df4f7748..f6fc9d3d60 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -31,12 +31,8 @@ DISTDIR=dist ( cd $DISTDIR for x in * ; do - # FIXME: Remove this logic once these packages are available in Pypi - if echo "$x" | grep -Eq "^opentelemetry_resource_detector_container.*(\.tar\.gz|\.whl)$"; then - echo "Skipping $x because of erroneous uploads. See: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2053" - rm $x # FIXME: Remove this once opentelemetry-resource-detector-azure package goes 1.X - elif echo "$x" | grep -Eq "^opentelemetry_resource_detector_azure.*(\.tar\.gz|\.whl)$"; then + if echo "$x" | grep -Eq "^opentelemetry_resource_detector_azure.*(\.tar\.gz|\.whl)$"; then echo "Skipping $x because of manual upload by Azure maintainers." rm $x # NOTE: We filter beta vs 1.0 package at this point because we can read the diff --git a/tox.ini b/tox.ini index 55c7d4c238..b37982567a 100644 --- a/tox.ini +++ b/tox.ini @@ -25,10 +25,10 @@ envlist = # pypy3-test-instrumentation-google-genai-{0,1} lint-instrumentation-google-genai - ; opentelemetry-resource-detector-container - py3{9,10,11,12,13}-test-resource-detector-container - pypy3-test-resource-detector-container - lint-resource-detector-container + ; opentelemetry-resource-detector-containerid + py3{9,10,11,12,13}-test-resource-detector-containerid + pypy3-test-resource-detector-containerid + lint-resource-detector-containerid ; opentelemetry-resource-detector-azure py3{9,10,11,12,13}-test-resource-detector-azure-{0,1} @@ -686,8 +686,8 @@ deps = lint-sdk-extension-aws: -r {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements-0.txt benchmark-sdk-extension-aws: -r {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws/benchmark-requirements.txt - resource-detector-container: {[testenv]test_deps} - resource-detector-container: -r {toxinidir}/resource/opentelemetry-resource-detector-container/test-requirements.txt + resource-detector-containerid: {[testenv]test_deps} + resource-detector-containerid: -r {toxinidir}/resource/opentelemetry-resource-detector-containerid/test-requirements.txt # packages that are released individually should provide a test-requirements.txt with the lowest version of OTel API # and SDK supported to test we are honoring it @@ -913,8 +913,8 @@ commands = lint-sdk-extension-aws: sh -c "cd sdk-extension && pylint --rcfile ../.pylintrc opentelemetry-sdk-extension-aws" benchmark-sdk-extension-aws: pytest {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws/benchmarks {posargs} --benchmark-json=sdk-extension-aws-benchmark.json - test-resource-detector-container: pytest {toxinidir}/resource/opentelemetry-resource-detector-container/tests {posargs} - lint-resource-detector-container: sh -c "cd resource && pylint --rcfile ../.pylintrc opentelemetry-resource-detector-container" + test-resource-detector-containerid: pytest {toxinidir}/resource/opentelemetry-resource-detector-containerid/tests {posargs} + lint-resource-detector-containerid: sh -c "cd resource && pylint --rcfile ../.pylintrc opentelemetry-resource-detector-containerid" test-resource-detector-azure: pytest {toxinidir}/resource/opentelemetry-resource-detector-azure/tests {posargs} lint-resource-detector-azure: sh -c "cd resource && pylint --rcfile ../.pylintrc opentelemetry-resource-detector-azure" @@ -1050,6 +1050,6 @@ deps = {toxinidir}/instrumentation-genai/opentelemetry-instrumentation-google-genai[instruments] {toxinidir}/instrumentation/opentelemetry-instrumentation-aiokafka[instruments] {toxinidir}/instrumentation/opentelemetry-instrumentation-asyncclick[instruments] - + commands = pyright