Registry / observability / opentelemetry-resourcedetector-process

opentelemetry-resourcedetector-process

JSON →
library0.3.0pypypi✓ verified 27d ago

This OpenTelemetry package populates Resource attributes from the running process. It detects process-related information such as PID, executable name, command line, and runtime details, which are then attached to telemetry data for better context and filtering. The current version is 0.3.0, and releases appear to be ad-hoc, following updates in the broader OpenTelemetry Python ecosystem.

pip install opentelemetry-resourcedetector-process
INSTALL
IMPORT
SIG · OPENTELEMETRY-RESO
O
opentelemetry-resourcedetector-process
observabilitypythonv0.3.0
Install
2.2s avg
Import
235ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.0 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.240s · 22.6MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 2.2s · import 0.230s · 23MB
21MB installed
● package 21MB
Code
Verified usage

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

ProcessResourceDetector
✓ from opentelemetry_resourcedetector_process import ProcessResourceDetector
get_aggregated_resources
✓ from opentelemetry.sdk.resources import get_aggregated_resources
Used to combine multiple resource detectors.

Demonstrates how to import and use `ProcessResourceDetector` to gather process-specific attributes and combine them with other resource attributes using `get_aggregated_resources`.

from opentelemetry.sdk.resources import get_aggregated_resources from opentelemetry_resourcedetector_process import ProcessResourceDetector # Instantiate the process resource detector process_detector = ProcessResourceDetector() # Aggregate resources, including the process detector # Note: The OpenTelemetry SDK often includes built-in detectors by default, # but if you are manually creating an aggregated resource, you must explicitly # list all desired detectors. resource = get_aggregated_resources([ process_detector, # Add other detectors here if needed, e.g., HostResourceDetector() ]) print("Detected Process Resource Attributes:") for key, value in resource.attributes.items(): print(f" {key}: {value}") # In a real OpenTelemetry setup, this 'resource' object would be passed # to a TracerProvider, MeterProvider, or LoggerProvider. # Example (conceptual): # from opentelemetry.sdk.trace import TracerProvider # tracer_provider = TracerProvider(resource=resource) # # ... further setup ...
Debug
Known issues
breakingPython version requirement changed. Version 0.3.0 and later require Python >=3.8. Previous versions (e.g., 0.2.0) supported Python >=3.6.
fix
Ensure your project uses Python 3.8 or newer, or pin to an older `opentelemetry-resourcedetector-process` version if Python 3.6/3.7 support is critical.
affects: >=0.3.0
gotchaWhen manually constructing `Resource` objects or using `get_aggregated_resources`, you must explicitly include `ProcessResourceDetector()` in the list of detectors to ensure process attributes are collected. It is not automatically added if you provide your own list.
fix
Always pass `ProcessResourceDetector()` to `get_aggregated_resources` or `Resource.create` if you intend to collect process attributes.
affects: All versions
gotchaOpenTelemetry Semantic Conventions, which define attribute names (e.g., `process.pid`, `process.executable.name`), can evolve. While this detector provides these attributes, their precise names or expected values might change with future OpenTelemetry specification updates.
fix
Periodically consult the official OpenTelemetry Semantic Conventions for resource attributes to ensure compatibility with your observability backend and dashboards.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'opentelemetry_resourcedetector_process'
This error occurs when the 'opentelemetry-resourcedetector-process' package is not installed in the Python environment, or is installed but the import statement uses an incorrect path.
fix
Ensure the package is installed using pip: `pip install opentelemetry-resourcedetector-process`
Exception in detector <opentelemetry.resource.detector.<RESOURCE DETECTOR CLASS> object at 0x...>, ignoring.
This warning, especially when the exception string appears blank or the application hangs, indicates that a resource detector (like the ProcessResourceDetector) took longer than its default timeout (5 seconds) to complete its detection logic.
fix
Increase the timeout for resource detection (e.g., using `OTEL_EXPERIMENTAL_RESOURCE_DETECTOR_TIMEOUT` environment variable if available in newer SDK versions, or by ensuring custom detectors complete quickly). For the `ProcessResourceDetector`, ensure the `/proc` filesystem is accessible and not experiencing I/O delays in containerized environments.
from opentelemetry.sdk.resources import ProcessResourceDetector
Developers often incorrectly assume that all OpenTelemetry resource detectors are part of the core `opentelemetry.sdk.resources` module. However, `ProcessResourceDetector` is from the `opentelemetry-resourcedetector-process` package.
fix
The correct import statement is `from opentelemetry_resourcedetector_process import ProcessResourceDetector`.
Process Detection Failed
This general error message or log entry indicates that the process resource detector was unable to collect the expected process-related information, often due to permission issues (e.g., restricted access to `/proc` filesystem in certain container configurations) or other environmental constraints.
fix
Verify that the application has the necessary permissions to access process information (e.g., read access to `/proc` in Linux environments). In containerized setups, ensure the container's security context or Docker run flags (like `--pid=host`) allow access to host process details if needed, or that the container environment itself provides the necessary process information.
Upgrade
Version history
0.3.0latest on PyPI · released Sep 18, 2022
Audit
Dependencies
opentelemetry-sdkrequiredRequired for aggregating resource detectors into a Resource object and for OpenTelemetry SDK functionality.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
opentelemetry-resourcedetector-process — pip install opentelemetry-resourcedetector-process · libregistry