Skip to content

Commit 4a2ef8c

Browse files
avinab-neogyxrmx
andauthored
docs: update logs example to use opentelemetry-instrumentation-logging (#5344)
* docs: update logs example to use opentelemetry-instrumentation-logging * docs: restore experimental warning, keep scope focused on LoggingHandler * add changelog fragment for #5344 * docs: address review feedback, use deprecated and update propagate comment * Apply suggestion from @xrmx * Apply suggestion from @xrmx --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent e6f2809 commit 4a2ef8c

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

.changelog/5344.changed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs: update logs example to use `opentelemetry-instrumentation-logging`

docs/examples/logs/README.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ OpenTelemetry Logs SDK
88

99
The source files of these examples are available :scm_web:`here <docs/examples/logs/>`.
1010

11+
.. note::
12+
13+
``LoggingHandler`` has moved from the SDK to the
14+
``opentelemetry-instrumentation-logging`` package in the contrib repo
15+
and is deprecated in ``opentelemetry-sdk``.
16+
17+
18+
Installation
19+
------------
20+
21+
.. code-block:: sh
22+
23+
pip install opentelemetry-api
24+
pip install opentelemetry-sdk
25+
pip install opentelemetry-exporter-otlp-proto-grpc
26+
pip install opentelemetry-instrumentation-logging
27+
28+
Run the Example
29+
---------------
30+
1131
Start the Collector locally to see data being exported. Write the following file:
1232

1333
.. code-block:: yaml

docs/examples/logs/example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
# Create different namespaced loggers
4949
# It is recommended to not use the root logger with OTLP handler
5050
# so telemetry is collected only for the application
51+
# Logger.propagate is True by default, ensure it is not set to False so log
52+
# records reach the root logger handler. See
53+
# https://docs.python.org/3/library/logging.html#logging.Logger.propagate
5154
logger1 = logging.getLogger("myapp.area1")
5255
logger2 = logging.getLogger("myapp.area2")
5356

0 commit comments

Comments
 (0)