Python Logs Auto-Instrumentation

Collecting Python Application Logs Using Auto-Instrumentation

If you are using python auto-instrumentation for instrumenting your python application you can send logs to SigNoz easily with auto-instrumentation.

To enable logs auto-instrumentation just add this environment variable


Example application

Here is a sample python application

  1. Create a file named and paste the following code

    from flask import Flask
    import logging
    app = Flask(__name__)
    def hello_world():
        logging.warning("hello world log message")
        return 'Hello World'
    if __name__ == '__main__':
  2. Create a virual environment

    python -m venv venv
    source ./venv/bin/activate
  3. Install dependencies

    pip install opentelemetry-distro
    pip install flask requests
    pip install opentelemetry-exporter-otlp
  4. Run the opentelemetry-bootstrap command:

    opentelemetry-bootstrap -a install
  5. Run the application

    OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true opentelemetry-instrument --traces_exporter none --metrics_exporter none --logs_exporter console python

You will be able to see the otel logs on the console once you visit http://localhost:5000

If you want to send data to SigNoz cloud or self host SigNoz the run command will change and will be described in the next steps

For SigNoz Cloud the run command will be

opentelemetry-instrument --traces_exporter otlp --metrics_exporter otlp --logs_exporter otlp python
  • The value of SIGNOZ_ENDPOINT will be https://ingest.{region} where depending on the choice of your region for SigNoz cloud, the otlp endpoint will vary according to this table.
  • The value of INGESTION_KEY is your ingestion key.