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
1 change: 1 addition & 0 deletions .changelog/5344.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs: update logs example to use `opentelemetry-instrumentation-logging`
20 changes: 20 additions & 0 deletions docs/examples/logs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ OpenTelemetry Logs SDK

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

.. note::

``LoggingHandler`` has moved from the SDK to the
``opentelemetry-instrumentation-logging`` package in the contrib repo
and is deprecated in ``opentelemetry-sdk``.


Installation
------------

.. code-block:: sh

pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-exporter-otlp-proto-grpc
pip install opentelemetry-instrumentation-logging

Run the Example
---------------

Start the Collector locally to see data being exported. Write the following file:

.. code-block:: yaml
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/logs/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
logger1 = logging.getLogger("myapp.area1")
logger2 = logging.getLogger("myapp.area2")

# Propagate is True by default, ensure it is not set to False so log
# records reach the root logger handler. See
# https://docs.python.org/3/library/logging.html#logging.Logger.propagate

logger1.debug("Quick zephyrs blow, vexing daft Jim.")
logger1.info("How quickly daft jumping zebras vex.")
logger2.warning("Jail zesty vixen who grabbed pay from quack.")
Expand Down