Skip to content

Commit df0832f

Browse files
committed
Fix broken link in Prometheus exporter README and add missing documentation
Fixes #4399 Signed-off-by: Yogi Suthari <[email protected]>
1 parent 534cd38 commit df0832f

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Fix broken documentation link in Prometheus exporter README and add missing Prometheus exporter documentation (#4399)
1011
- Fix user agent in OTLP HTTP metrics exporter
1112
([#4475](https://github.com/open-telemetry/opentelemetry-python/pull/4475))
1213
- Improve performance of baggage operations

Diff for: docs/exporter/prometheus/prometheus.rst

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
OpenTelemetry Prometheus Exporter
2+
================================
3+
4+
.. automodule:: opentelemetry.exporter.prometheus
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
Installation
10+
-----------
11+
12+
The OpenTelemetry Prometheus Exporter package is available on PyPI::
13+
14+
pip install opentelemetry-exporter-prometheus
15+
16+
Usage
17+
-----
18+
19+
The Prometheus exporter starts an HTTP server that collects metrics and serializes them to
20+
Prometheus text format on request::
21+
22+
from prometheus_client import start_http_server
23+
24+
from opentelemetry import metrics
25+
from opentelemetry.exporter.prometheus import PrometheusMetricReader
26+
from opentelemetry.sdk.metrics import MeterProvider
27+
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
28+
29+
# Service name is required for most backends
30+
resource = Resource(attributes={
31+
SERVICE_NAME: "your-service-name"
32+
})
33+
34+
# Start Prometheus client
35+
start_http_server(port=9464, addr="localhost")
36+
# Initialize PrometheusMetricReader which pulls metrics from the SDK
37+
# on-demand to respond to scrape requests
38+
reader = PrometheusMetricReader()
39+
provider = MeterProvider(resource=resource, metric_readers=[reader])
40+
metrics.set_meter_provider(provider)
41+
42+
Configuration
43+
------------
44+
45+
The following environment variables are supported:
46+
47+
* ``OTEL_EXPORTER_PROMETHEUS_HOST`` (default: "localhost"): The host to bind to
48+
* ``OTEL_EXPORTER_PROMETHEUS_PORT`` (default: 9464): The port to bind to
49+
50+
References
51+
----------
52+
53+
* `Prometheus <https://prometheus.io/>`_
54+
* `OpenTelemetry Project <https://opentelemetry.io/>`_

Diff for: exporter/opentelemetry-exporter-prometheus/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ Installation
1818
References
1919
----------
2020

21-
* `OpenTelemetry Prometheus Exporter <https://opentelemetry-python.readthedocs.io/en/latest/exporter/prometheus/prometheus.html>`_
21+
* `OpenTelemetry Prometheus Exporter <https://opentelemetry.io/docs/instrumentation/python/exporters/#prometheus>`_
2222
* `Prometheus <https://prometheus.io/>`_
2323
* `OpenTelemetry Project <https://opentelemetry.io/>`_

0 commit comments

Comments
 (0)