OpenTelemetry Python Instrumentation
Get up and running with OpenTelemetry in just a few quick steps! The setup process consists of two phases--getting OpenTelemetry installed and configured, and then validating that configuration to ensure that data is being sent as expected. This guide explains how to download, install, and run OpenTelemetry in Python.
Requirements
- Python 3.4 or newer
- An app to add OpenTelemetry to
We follow OpenTelemetry python instrumentation library. We shall be exporting data in Jaeger Thrift protocol.
caution
If it hangs while installing grpcio
during pip3 install opentelemetry-exporter-otlp then follow below steps as suggested in this stackoverflow link
- pip3 install --upgrade pip
- python3 -m pip install --upgrade setuptools
- pip3 install --no-cache-dir --force-reinstall -Iv grpcio
The above command inspects the active Python site-packages and figures out which instrumentation packages the user might want to install and installs them for you.
caution
If it says cannot find command opentelemetry-bootstrap
then you need to specify the path of the file. In ubuntu, it is at /home/ubuntu/.local/bin/opentelemetry-bootstrap
. So your command becomes,
/home/ubuntu/.local/bin/opentelemetry-bootstrap --action=install
#
Run Command- Self Hosted
- Cloud
<service_name> is the name of service you want
<your_run_command> can be python3 app.py
or flask run
caution
- If opentelemetry-instrument command is not found then use full path of executable. In ubuntu it is at /home/ubuntu/.local/bin/opentelemetry-instrument
- Remember to allow incoming requests to port 4317 of machine where SigNoz backend is hosted
<service_name> is the name of service you want
<your_run_command> can be python3 app.py
or flask run
<access_token> can be found in your settings page as shown in below image
caution
- If opentelemetry-instrument command is not found then use full path of executable. In ubuntu it is at /home/ubuntu/.local/bin/opentelemetry-instrument
#
Troubleshooting your installationIf spans are not being reported to SigNoz, try running in debug mode by setting OTEL_LOG_LEVEL=debug
:
The debug log level will print out the configuration information. It will also emit every span to the console, which should look something like: