Registry / observability / opentelemetry-resource-detector-containerid

opentelemetry-resource-detector-containerid

JSON →
library0.63b1pypypiunverified

Detects container ID from cgroup or container runtime to enrich OpenTelemetry resource attributes. Current version 0.62b1, beta release. Part of opentelemetry-python-contrib releases, cadence aligned with OpenTelemetry Python releases.

pip install opentelemetry-resource-detector-containerid
INSTALL
IMPORT
SIG · OPENTELEMETRY-RESO
O
opentelemetry-resource-detector-containerid
observabilitypythonv0.63b1
Install
2.6s avg
Import
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.63b1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.000s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ContainerIDResourceDetector
from opentelemetry.resource.detector.container import ContainerIDResourceDetector
from opentelemetry.resource.detector.container import ContainerIDResourceDetector

Detect container ID and merge into a resource. Newer SDKs require get_aggregated_resources; detect() is deprecated.

from opentelemetry import trace from opentelemetry.resource.detector.container import ContainerIDResourceDetector from opentelemetry.sdk.resources import get_aggregated_resources # Create a resource detector instance detector = ContainerIDResourceDetector() # For the latest SDK, use get_aggregated_resources to merge multiple detectors resource = get_aggregated_resources([detector]) # Or if using older SDK (pre-1.25): # resource = detector.detect() print(resource.attributes.get('container.id', 'no container ID found'))
Debug
Known issues
deprecatedThe method `detect()` on ContainerIDResourceDetector is deprecated in favor of `get_aggregated_resources` from opentelemetry.sdk.resources.
fix
Use `get_aggregated_resources([detector])` instead of `detector.detect()`.
affects: >=1.25.0
gotchaContainer ID detection requires access to /proc/self/cgroup or /proc/1/cgroup and may fail in environments without cgroup v1 or v2. On some container runtimes (e.g., Podman), the ID format differs.
fix
Ensure the container runtime exposes cgroup files. Use `container.id` attribute only when the detector succeeds; fall back to a default value if needed.
affects: All
gotchaThe detector is part of `opentelemetry-python-contrib` and does not include OpenTelemetry SDK itself. Users must install `opentelemetry-sdk` separately.
fix
Install opentelemetry-sdk: `pip install opentelemetry-sdk`.
affects: All
Upgrade
Version history
0.63b1latest on PyPI · released May 21, 2026
Audit
Dependencies
opentelemetry-sdkrequiredRequired for Resource class and SDK integration
opentelemetry-apirequiredProvides base types and API
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
opentelemetry-resource-detector-containerid — pip install opentelemetry-resource-detector-containerid · libregistry