Start without code changes
Start Vigilon by prefixing your usual startup command, without adding any code to your app.
Prefix your startup command
The SDK installs a command-line launcher called opentelemetry-instrument. It reads the same environment variables as the Python quickstart, starts Vigilon, and then runs your app. The name comes from OpenTelemetry, the open standard the SDK is built on. You do not need to know OpenTelemetry to use it.
Install the SDK and set the environment variables as in steps 1 and 2 of the quickstart. Skip telemetry.py, and put the launcher in front of your usual command:
opentelemetry-instrument python app.py
# FastAPI with Uvicorn:
opentelemetry-instrument uvicorn main:app
# Flask development server:
opentelemetry-instrument flask --app main run --no-reload
The examples turn off the development server’s auto-reloader, which does not work with the launcher.
The launcher requires non-empty VIGILON_API_KEY, VIGILON_SERVICE_NAME, and VIGILON_ENVIRONMENT values. VIGILON_SERVICE_VERSION is recommended, and the launcher logs a warning if it is missing. VIGILON_EXCLUDED_URLS leaves out extra routes, and VIGILON_OTEL_ENDPOINT overrides where data is sent.
Django
Export the settings module in the shell or deployment environment. Setting it only in manage.py is too late for the launcher. This example uses Django’s development server:
export DJANGO_SETTINGS_MODULE="myproject.settings"
opentelemetry-instrument python manage.py runserver --noreload
When not to use the launcher
Do not use the launcher with Gunicorn, uWSGI, or Celery prefork. Those servers create their worker processes after startup, and Vigilon has to start inside each worker. Follow the Worker processes guide instead.
Use either the launcher or start_vigilon(), not both. If your app also calls register(), Vigilon logs a warning and ignores that call.
If your environment already has another OpenTelemetry distribution installed, the launcher may not pick Vigilon. See “Nothing arrives” in the Troubleshooting guide.