{"library":"opentelemetry-resourcedetector-docker","title":"OpenTelemetry Docker Resource Detector","description":"opentelemetry-resourcedetector-docker is a Python package for OpenTelemetry that automatically enriches telemetry data with resource attributes derived from the Docker container environment where the application is running. Currently at version 0.4.0, it is actively maintained with releases as needed to align with OpenTelemetry Python SDK and address Docker-related detection specifics.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install opentelemetry-resourcedetector-docker"],"cli":null},"imports":["from opentelemetry_resourcedetector_docker import DockerResourceDetector","from opentelemetry.sdk.resources import get_aggregated_resources"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom opentelemetry.sdk.resources import get_aggregated_resources\nfrom opentelemetry_resourcedetector_docker import DockerResourceDetector\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\n\n# Configure the resource detector. DockerResourceDetector requires access to the Docker socket.\n# Ensure your application has read access to /var/run/docker.sock (Linux) or similar.\n# For demonstration, we'll try to detect, but actual attributes depend on Docker environment.\nresource = get_aggregated_resources([\n    DockerResourceDetector()\n])\n\n# Optional: Add a service name if not detected by environment variables or other detectors\nif not resource.attributes.get('service.name'):\n    resource = resource.merge(Resource({'service.name': 'my-docker-app'}))\n\n# Set up a TracerProvider with the detected resource\nprovider = TracerProvider(resource=resource)\n\n# Configure a simple console exporter for demonstration\nspan_processor = SimpleSpanProcessor(ConsoleSpanExporter())\nprovider.add_span_processor(span_processor)\n\n# Set the global tracer provider\nfrom opentelemetry import trace\ntrace.set_tracer_provider(provider)\n\n# Get a tracer and create a span\ntracer = trace.get_tracer(__name__)\n\nwith tracer.start_as_current_span(\"my-docker-operation\") as span:\n    span.set_attribute(\"environment\", os.environ.get('APP_ENV', 'development'))\n    print(f\"Span created with resource attributes: {resource.attributes}\")\n    print(\"Look for 'container.id' or other Docker-related attributes in the output.\")","lang":"python","description":"This quickstart demonstrates how to initialize the OpenTelemetry SDK with the `DockerResourceDetector` to automatically gather Docker-related resource attributes. The collected attributes are then used by a `TracerProvider` and printed to the console via a `ConsoleSpanExporter`. Ensure Docker is running and the application has permissions to access the Docker socket for successful detection.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.4.0","pypi_latest":"0.4.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.1,"avg_import_s":0.26,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.27,"mem_mb":12.5,"disk_size":"22.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.18,"mem_mb":12.5,"disk_size":"23M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.32,"mem_mb":13.2,"disk_size":"24.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0.28,"mem_mb":13.2,"disk_size":"25M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.29,"mem_mb":13.2,"disk_size":"16.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2,"import_time_s":0.3,"mem_mb":13.2,"disk_size":"17M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.29,"mem_mb":13.4,"disk_size":"16.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.28,"mem_mb":13.4,"disk_size":"17M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.22,"mem_mb":12.3,"disk_size":"22.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"opentelemetry-resourcedetector-docker","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.19,"mem_mb":12.3,"disk_size":"22M"}]}}