Skip to content

Commit 05343a5

Browse files
jscancellatammy-baylis-swixrmx
authored
docs: updated the "Read The Docs" documentation (#4728)
* docs: updated the ReadTheDocs documentation to all have links to the examples for consistency * Update docs/examples/metrics/prometheus-grafana/README.rst Co-authored-by: Tammy Baylis <[email protected]> * Added changelog entry as requested in PR feedback * fixed link to localhost to see the metrics * just use a plain http link * Update CHANGELOG.md Co-authored-by: Riccardo Magliocchetti <[email protected]> * fix tox reported issues * fix capitalization of Prometheus * Update CHANGELOG.md --------- Co-authored-by: Tammy Baylis <[email protected]> Co-authored-by: Riccardo Magliocchetti <[email protected]>
1 parent 7e45772 commit 05343a5

File tree

8 files changed

+76
-4
lines changed

8 files changed

+76
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
1313
## Unreleased
1414

15+
- docs: linked the examples with their github source code location and added Prometheus example
16+
([#4728](https://github.com/open-telemetry/opentelemetry-python/pull/4728))
17+
1518
## Version 1.36.0/0.57b0 (2025-07-29)
1619

1720
- Add missing Prometheus exporter documentation

docs/examples/django/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Django Instrumentation
44
This shows how to use ``opentelemetry-instrumentation-django`` to automatically instrument a
55
Django app.
66

7-
For more user convenience, a Django app is already provided in this directory.
7+
The source files of these examples are available :scm_web:`here <docs/examples/django/>`.
88

99
Preparation
1010
-----------

docs/examples/error_handler/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Overview
66

77
This example shows how to use the global error handler.
88

9+
The source files of these examples are available :scm_web:`here <docs/examples/error_handler/>`.
910

1011
Preparation
1112
-----------

docs/examples/fork-process-model/README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ get around this limitation of the span processor.
1010
Please see http://bugs.python.org/issue6721 for the problems about Python locks in (multi)threaded
1111
context with fork.
1212

13+
The source code for the examples with Flask app are available :scm_web:`here <docs/examples/fork-process-model/>`.
14+
1315
Gunicorn post_fork hook
1416
-----------------------
1517

@@ -61,6 +63,3 @@ uWSGI postfork decorator
6163
OTLPSpanExporter(endpoint="http://localhost:4317")
6264
)
6365
trace.get_tracer_provider().add_span_processor(span_processor)
64-
65-
66-
The source code for the examples with Flask app are available :scm_web:`here <docs/examples/fork-process-model/>`.

docs/examples/logs/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ OpenTelemetry Logs SDK
66
:mod:`opentelemetry.sdk._logs` are subject to change in minor/patch releases and make no
77
backward compatibility guarantees at this time.
88

9+
The source files of these examples are available :scm_web:`here <docs/examples/logs/>`.
10+
911
Start the Collector locally to see data being exported. Write the following file:
1012

1113
.. code-block:: yaml

docs/examples/metrics/instruments/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
OpenTelemetry Metrics SDK
22
=========================
33

4+
The source files of these examples are available :scm_web:`here <docs/examples/metrics/instruments/>`.
5+
46
Start the Collector locally to see data being exported. Write the following file:
57

68
.. code-block:: yaml
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Prometheus Instrumentation
2+
==========================
3+
4+
This shows how to use ``opentelemetry-exporter-prometheus`` to automatically generate Prometheus metrics.
5+
6+
The source files of these examples are available :scm_web:`here <docs/examples/prometheus-grafana/>`.
7+
8+
Preparation
9+
-----------
10+
11+
This example will be executed in a separate virtual environment:
12+
13+
.. code-block::
14+
15+
$ mkdir prometheus_auto_instrumentation
16+
$ virtualenv prometheus_auto_instrumentation
17+
$ source prometheus_auto_instrumentation/bin/activate
18+
19+
20+
Installation
21+
------------
22+
23+
.. code-block::
24+
25+
$ pip install -r requirements.txt
26+
27+
28+
Execution
29+
---------
30+
31+
.. code-block::
32+
33+
$ python ./prometheus-monitor.py
34+
$ Server is running at http://localhost:8000
35+
36+
Now you can visit http://localhost:8000/metrics to see Prometheus metrics.
37+
You should see something like:
38+
39+
.. code-block::
40+
41+
# HELP python_gc_objects_collected_total Objects collected during gc
42+
# TYPE python_gc_objects_collected_total counter
43+
python_gc_objects_collected_total{generation="0"} 320.0
44+
python_gc_objects_collected_total{generation="1"} 58.0
45+
python_gc_objects_collected_total{generation="2"} 0.0
46+
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
47+
# TYPE python_gc_objects_uncollectable_total counter
48+
python_gc_objects_uncollectable_total{generation="0"} 0.0
49+
python_gc_objects_uncollectable_total{generation="1"} 0.0
50+
python_gc_objects_uncollectable_total{generation="2"} 0.0
51+
# HELP python_gc_collections_total Number of times this generation was collected
52+
# TYPE python_gc_collections_total counter
53+
python_gc_collections_total{generation="0"} 61.0
54+
python_gc_collections_total{generation="1"} 5.0
55+
python_gc_collections_total{generation="2"} 0.0
56+
# HELP python_info Python platform information
57+
# TYPE python_info gauge
58+
python_info{implementation="CPython",major="3",minor="8",patchlevel="5",version="3.8.5"} 1.0
59+
# HELP MyAppPrefix_my_counter_total
60+
# TYPE MyAppPrefix_my_counter_total counter
61+
MyAppPrefix_my_counter_total 964.0
62+
63+
``MyAppPrefix_my_counter_total`` is the custom counter created in the application with the custom prefix ``MyAppPrefix``.

docs/examples/metrics/prometheus-grafana/prometheus-monitor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
my_counter = meter.create_counter("my.counter")
2020

21+
print("Server is running at http://localhost:8000")
22+
2123
while 1:
2224
my_counter.add(random.randint(1, 10))
2325
time.sleep(random.random())

0 commit comments

Comments
 (0)