Registry / observability / opentelemetry-instrumentation-system-metrics

opentelemetry-instrumentation-system-metrics

JSON →
library0.65b0pypypi✓ verified 23d ago

OpenTelemetry System Metrics Instrumentation provides an automated way to collect system-level performance metrics such as CPU, memory, network, and disk I/O. It is part of the `opentelemetry-python-contrib` project, currently in beta version `0.61b0`, and packages are released on a roughly monthly cadence.

pip install opentelemetry-instrumentation-system-metrics opentelemetry-sdk psutil
INSTALL
IMPORT
SIG · OPENTELEMETRY-INST
O
opentelemetry-instrumentation-system-metrics
observabilitypythonv0.65b0
Install
3.0s avg
Import
493ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.65b0 · 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.532s · 24.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.0s · import 0.454s · 25MB
23MB installed
● package 23MB
Code
Verified usage

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

SystemMetricsInstrumentor
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
MeterProvider
from opentelemetry.sdk.metrics import MeterProvider
PeriodicExportingMetricReader
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
ConsoleMetricExporter
from opentelemetry.sdk.metrics.export import ConsoleMetricExporter
set_meter_provider
from opentelemetry.sdk.metrics import set_meter_provider

This quickstart demonstrates how to set up the OpenTelemetry SDK with a `MeterProvider` and a `ConsoleMetricExporter` to print collected metrics to the console. It then instruments system metrics using `SystemMetricsInstrumentor().instrument()`, which starts collecting CPU, memory, disk, and network metrics asynchronously.

import time from opentelemetry.sdk.metrics import MeterProvider, set_meter_provider from opentelemetry.sdk.metrics.export import ConsoleMetricExporter, PeriodicExportingMetricReader from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor # Configure MeterProvider exporter = ConsoleMetricExporter() reader = PeriodicExportingMetricReader(exporter, export_interval_millis=1000) set_meter_provider(MeterProvider([reader])) # Instrument system metrics SystemMetricsInstrumentor().instrument() print("Collecting system metrics... Press Ctrl+C to exit.") try: while True: time.sleep(5) # Metrics are collected asynchronously except KeyboardInterrupt: print("Exiting.")
Debug
Known issues
deprecatedOut-of-spec `process.runtime` prefixed metrics are deprecated and will be removed in future versions. Users are encouraged to migrate to standard process metrics.
fix
Review your metric consumers for usage of `process.runtime.*` metrics and update to the recommended standard process metrics. Refer to OpenTelemetry semantic conventions for current metric names.
affects: All versions up to 0.61b0
gotchaThe instrumentation library is still in beta, indicating that its API and collected telemetry might undergo breaking changes in future releases as the OpenTelemetry specification evolves.
fix
Monitor release notes of `opentelemetry-python-contrib` for breaking changes and adjust your code and configurations accordingly. Consider pinning to specific minor versions for stability.
affects: All beta versions (e.x., <1.0.0)
gotchaSpecific system and process metrics can be excluded from collection using the `OTEL_PYTHON_SYSTEM_METRICS_EXCLUDED_METRICS` environment variable. This is useful for reducing telemetry cardinality or focusing on specific metrics.
fix
Set the `OTEL_PYTHON_SYSTEM_METRICS_EXCLUDED_METRICS` environment variable with a comma-separated list of glob patterns matching metric names to exclude (e.g., `export OTEL_PYTHON_SYSTEM_METRICS_EXCLUDED_METRICS="system.cpu.*,process.memory.usage"`).
affects: All versions
gotchaIn versions prior to `v0.48b0`, the `process.runtime.cpu.utilization` metric might report values outside the expected range of 0 to 1.
fix
Upgrade to `opentelemetry-instrumentation-system-metrics` version `0.48b0` or newer to ensure `process.runtime.cpu.utilization` values are correctly normalized to the 0-1 range.
affects: <0.48b0
Upgrade
Version history
0.65b0latest on PyPI · released Jul 16, 2026
Audit
Dependencies
opentelemetry-apirequiredCore OpenTelemetry API for defining telemetry.
opentelemetry-sdkrequiredOpenTelemetry SDK for processing and exporting telemetry.
psutilrequiredRequired for collecting system and process metrics.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources