Skip to content

Latest commit

 

History

History

Get Started Guide - Python

This is the solution (completely instrumented with OpenTelemetry) for the Python demo application used in the Get Started Guide - Python doc.

Requires:

To run this demo app via the CLI, follow the steps below. For steps 2-10, refer to the table below to find the commands to use for your environment.

  1. Switch to the working directory:
cd ./getting-started-guides/python/instrumented/
  1. Install virtualenv, if not already done
  2. Create a virtual environment for the application
  3. Activate virtual environment
  4. Upgrade pip in virtual environment
  5. Install dependencies listed in requirements.txt
  6. To send telemetry data to New Relic, set the following environment variables
OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp.nr-data.net"
OTEL_EXPORTER_OTLP_HEADERS="api-key=[YOUR_INGEST_KEY]"
  1. Set this environment variable to name the demo app:
OTEL_SERVICE_NAME=getting-started-python
  1. Run the app
  2. To generate traffic, in a new terminal tab run the load generator
  3. To shut down the program, run the following in both shells or terminal tabs: ctrl + c.

Commands table

Step Windows (PowerShell) Linux / MacOS (bash)
2 pip install virtualenv pip3 install virtualenv
3 python -m venv venv python3 -m venv venv
4 .\venv\Scripts\Activate.ps1 source venv/bin/activate
5 python -m pip install --upgrade pip python3 -m pip install --upgrade pip
6 pip install -r requirements.txt pip install -r requirements.txt
7-8 Set OTEL environment variables $Env: Set OTEL environment variables export
9 python app.py python3 app.py
10 .\load-generator.ps1 ./load-generator.sh