Installation

Follow the below steps to install Thundra Sidekick SDK to your application.

Configure the Agent

In order to configure the agent, you'll need an API key from Thundra Sidekick. You can see your API key in the Welcome Tab after log in.

Configure by Environment Variables

export THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY>
export THUNDRA_AGENT_APPLICATION_NAME=<application_name>
export THUNDRA_AGENT_APPLICATION_STAGE=<application_stage>
export THUNDRA_AGENT_APPLICATION_VERSION=<application_version>
export THUNDRA_AGENT_DEBUG_ENABLE=True

For Django, there are two additional environment variables for database configuration:

export THUNDRA_AGENT_TRACE_INTEGRATIONS_DJANGO_ORM_DISABLE=False
export THUNDRA_AGENT_TRACE_INTEGRATIONS_RDB_DISABLE=False

Configure by .env file

Create a file with the .env extension and add the following code snippet into it with your own environment variables.

THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY>
THUNDRA_AGENT_APPLICATION_NAME=<application_name>
THUNDRA_AGENT_APPLICATION_STAGE=<application_stage>
THUNDRA_AGENT_APPLICATION_VERSION=<application_version>
THUNDRA_AGENT_DEBUG_ENABLE=True

For Django, there are two additional variables for database configuration:

THUNDRA_AGENT_TRACE_INTEGRATIONS_DJANGO_ORM_DISABLE=False
THUNDRA_AGENT_TRACE_INTEGRATIONS_RDB_DISABLE=False

Sample Docker Configuration

Simple Django production-ready Docker file:

FROM python:3
# This is the port that Gunicorn uses, so expose it to the outside
# world.
EXPOSE 8000
# Don't just add the base code directory, to try to cut down on
# rebuild sizes.
RUN mkdir /code
WORKDIR /code
# Install all the requirements -- doing things in this order should
# reduce the size of redeployments if we don't change dependencies.
ADD requirements.txt /code/
RUN pip install -r requirements.txt
# Add the main code directory and point at the start script.
ADD . /code
CMD ["./start.sh"]

Start.sh file

#!/bin/bash
gunicorn --bind=0.0.0.0:8000 --workers=3 --access-logfile '-' --error-logfile '-' --capture-output conduit.wsgi

Configure environment variable:

docker run ... \
-e THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY> \
-e THUNDRA_AGENT_APPLICATION_NAME=<YOUR-APP-NAME> \
-e THUNDRA_AGENT_APPLICATION_STAGE=dev \
-e THUNDRA_AGENT_APPLICATION_VERSION=<YOUR-APP-VERSION> \
-e THUNDRA_AGENT_DEBUG_ENABLE=True \
...

Configure .env file:

After adding the code mentioned on the Configure the Agent by .env section, there is no need to add environment variables as command-line arguments. Execute following:

docker run ...

Add Thundra to Your Application

You should start the Thundra debugger before your app is initialized or started. For example, you can add the following snippet at the end of your settings.py for Django project or beginning of the file where you create Flask app such as app = Flask(name)

Configure by Environment Variable:

from pathlib import Path
from dotenv import load_dotenv
env_path = Path(<.env file path>).resolve()
load_dotenv(dotenv_path=env_path)
try:
import tracepointdebug
tracepointdebug.start()
except ImportError as e:
pass

Configure by .env File:

To install environment variables from the configuration file, you should install pathlib and dotenv first.

from pathlib import Path
from dotenv import load_dotenv
env_path = Path(<.env file path>).resolve()
load_dotenv(dotenv_path=env_path)
try:
import tracepointdebug
tracepointdebug.start()
except ImportError as e:
pass