From b45885ecc38bb7a58e43b85e5c390dcabcc1cba0 Mon Sep 17 00:00:00 2001 From: Steve Flanders Date: Thu, 4 Jan 2024 07:44:27 -0500 Subject: [PATCH] Update Python automatic instrumentation directions OTel Python automatic instrumentation doesn't support Flask or Werkzeug 3.0+. This will be addressed in [this PR](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2013) As a result, the automatic instrumentation example doesn't work. This has been an issue since Oct and reported in multiple issues across multiple repositories. The getting started automatic instrumentation does work as it's pinned to versions less than 3.0. Update the documentation for the automatic instrumentation so it work. Addresses: https://github.com/open-telemetry/opentelemetry-python/issues/3543 Also switch to venv over virtualenv to be consistent with getting started documentation and to remove an additional dependency. Once the above PR is merged, both the getting started and automatic instrumentation example documentation should be updated to remove the pinning. --- .../python/automatic/example.md | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/content/en/docs/instrumentation/python/automatic/example.md b/content/en/docs/instrumentation/python/automatic/example.md index 6acc43dd57cb..7769c070f583 100644 --- a/content/en/docs/instrumentation/python/automatic/example.md +++ b/content/en/docs/instrumentation/python/automatic/example.md @@ -87,8 +87,9 @@ following commands to prepare for auto-instrumentation: ```sh mkdir auto_instrumentation -virtualenv auto_instrumentation -source auto_instrumentation/bin/activate +cd auto_instrumentation +python -m venv venv +source ./venv/bin/activate ``` ## Install @@ -100,9 +101,16 @@ which provides several commands that help automatically instrument a program. ```sh pip install opentelemetry-distro -pip install opentelemetry-instrumentation-flask -pip install flask -pip install requests +pip install 'flask<3' 'werkzeug<3' requests +``` + +> **Note**: OpenTelemetry Python automatic instrumentation does not support Flask +> or Werkzeug 3.0+ at this time. + +Run the `opentelemetry-bootstrap` command: + +```shell +opentelemetry-bootstrap -a install ``` The examples that follow send instrumentation results to the console. Learn more @@ -130,12 +138,12 @@ Execute the server in two separate consoles, one to run each of the scripts that make up this example: ```sh -source auto_instrumentation/bin/activate +source ./venv/bin/activate python server_manual.py ``` ```sh -source auto_instrumentation/bin/activate +source ./venv/bin/activate python client.py testing ``` @@ -254,12 +262,12 @@ Execute the server just like you would do for manual instrumentation, in two separate consoles, one to run each of the scripts that make up this example: ```sh -source auto_instrumentation/bin/activate +source ./venv/bin/activate python server_programmatic.py ``` ```sh -source auto_instrumentation/bin/activate +source ./venv/bin/activate python client.py testing ```