Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Getting Started Guide - Python

This is a simple application instrumented with OpenTelemetry Python. It demonstrates how to configure OpenTelemetry Python to send data to New Relic.

Requirements

Running the application

  1. Set the following environment variables to configure OpenTelemetry to send data to New Relic:

    export OTEL_SERVICE_NAME=getting-started-python
    export OTEL_RESOURCE_ATTRIBUTES=service.instance.id=123
    export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
    export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net
    export OTEL_EXPORTER_OTLP_HEADERS=api-key=<your_license_key>
    export OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=4095
    export OTEL_EXPORTER_OTLP_COMPRESSION=gzip
    export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf 
    export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta
  2. Run the following command to install dependencies:

    python -m pip install -r requirements.txt
    opentelemetry-bootstrap -a install
  3. Run the application with the following command and open http://localhost:8080/fibonacci?n=1 in your web browser to ensure it is working.

    opentelemetry-instrument --logs_exporter otlp python3 app.py
  4. Experiment with providing different values for n in the query string. Valid values are between 1 and 90. Values outside this range cause an error which will show up in New Relic.