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-containeridVerified import paths — ran on the pinned version, not inferred.
Detect container ID and merge into a resource. Newer SDKs require get_aggregated_resources; detect() is deprecated.
Use `get_aggregated_resources([detector])` instead of `detector.detect()`.
Ensure the container runtime exposes cgroup files. Use `container.id` attribute only when the detector succeeds; fall back to a default value if needed.
Install opentelemetry-sdk: `pip install opentelemetry-sdk`.