Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#5120](https://github.com/open-telemetry/opentelemetry-python/pull/5120))
- Add WeaverLiveCheck test util
([#5088](https://github.com/open-telemetry/opentelemetry-python/pull/5088))
- `opentelemetry-exporter-prometheus`: add support for configuring scope info metric attributes for the Prometheus exporter
([#5123](https://github.com/open-telemetry/opentelemetry-python/pull/5123))

## Version 1.41.0/0.62b0 (2026-04-09)

Expand Down
42 changes: 41 additions & 1 deletion docs/exporter/prometheus/prometheus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,46 @@ Prometheus text format on request::
provider = MeterProvider(resource=resource, metric_readers=[reader])
metrics.set_meter_provider(provider)

Scope labels
------------

By default, the Prometheus exporter adds instrumentation scope information as
labels on every exported metric. These labels include ``otel_scope_name``,
``otel_scope_version``, and ``otel_scope_schema_url``. Instrumentation scope
attributes are exported with the ``otel_scope_`` prefix::

from prometheus_client import start_http_server

from opentelemetry import metrics
from opentelemetry.exporter.prometheus import PrometheusMetricReader
from opentelemetry.sdk.metrics import MeterProvider

start_http_server(port=9464, addr="localhost")
reader = PrometheusMetricReader()
provider = MeterProvider(metric_readers=[reader])
metrics.set_meter_provider(provider)

meter = metrics.get_meter(
"checkout",
"1.2.3",
schema_url="https://opentelemetry.io/schemas/1.21.0",
attributes={"region": "us-east-1"},
)
counter = meter.create_counter("orders")
counter.add(1, {"environment": "production"})

The exported metric includes labels such as
``otel_scope_name="checkout"``,
``otel_scope_version="1.2.3"``,
``otel_scope_schema_url="https://opentelemetry.io/schemas/1.21.0"``,
``otel_scope_region="us-east-1"``, and
``environment="production"``.

To omit instrumentation scope labels from exported metrics, set
``without_scope_info`` to ``True``::

reader = PrometheusMetricReader(without_scope_info=True)

Configuration
-------------

Expand All @@ -56,4 +96,4 @@ References
----------

* `Prometheus <https://prometheus.io/>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
Loading
Loading