Skip to main content
Connect your Python application to BugByBug using OpenTelemetry (OTel) auto-instrumentation. Once configured, your application can export trace data to BugByBug for continuous monitoring and AI-assisted error investigation. This guide uses the OpenTelemetry Python agent, so you can start collecting telemetry without adding instrumentation code throughout your application.

What you’ll need

Before you begin, make sure you have:
  • A Python application,
  • Python 3.10+ and pip installed,
  • A BugByBug account and project, and
  • Your BugByBug project API key.
This guide covers frameworks like FastAPI, Flask, Django, Celery, and standalone Python applications. Instrumentation coverage depends on the libraries and versions used by your application.

1. Get your API key

  1. Sign in to your BugByBug dashboard.
  2. Create or select an existing project.
  3. Copy the project’s API key.
Keep this key private. Do not commit it or expose it in frontend code.

2. Install the OpenTelemetry packages

Install the OpenTelemetry distribution and instrumentation tools:
Next, install the instrumentation packages for the libraries already used by your application:
The bootstrap command checks your installed Python packages and installs available OpenTelemetry instrumentation packages for supported libraries. For example, if your application uses Flask, Django, or requests, the command can install the corresponding instrumentation packages when available.

3. Configure BugByBug

Configure the OpenTelemetry exporter using environment variables. Add the following to your .env file or application environment:
Replace:
  • your-service-name with a recognizable name for your application or service.
  • YOUR_BUGBYBUG_API_KEY with your actual BugByBug project API key.
Important: The trace endpoint and authentication header above are the BugByBug connection details. The Python exporter must support the configured OTLP/HTTP JSON format. Confirm the exporter package and protocol compatibility before using this configuration in production.

4. Start your application with OpenTelemetry

Use the opentelemetry-instrument command to launch your application.

FastAPI / Uvicorn

Flask

Django / Gunicorn

Replace myproject with your Django project module.

Celery worker

Replace tasks with the module containing your Celery application.

Standalone Python script

Replace app.py with your application’s entry-point file. The instrumentation agent runs before your application and instruments supported libraries at runtime. You do not need to add the command separately to every route or function.

5. Verify your connection

After starting your application:
  1. Make a request to one of your application’s endpoints or run a task that exercises an instrumented library.
  2. Check your application logs for OpenTelemetry exporter errors.
  3. Open your BugByBug dashboard.
  4. Confirm that telemetry associated with your configured service appears.
If telemetry does not appear, check the troubleshooting section below before changing your application code.

Troubleshooting

What’s next?

Once your Python application is connected, BugByBug can begin receiving its configured telemetry for monitoring and investigation.