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

1
export THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY>
2
export THUNDRA_AGENT_APPLICATION_NAME=<application_name>
3
export THUNDRA_AGENT_APPLICATION_STAGE=<application_stage>
4
export THUNDRA_AGENT_APPLICATION_VERSION=<application_version>
5
export THUNDRA_AGENT_DEBUG_ENABLE=True
Copied!
For Django, there are two additional environment variables for database configuration:
1
export THUNDRA_AGENT_TRACE_INTEGRATIONS_DJANGO_ORM_DISABLE=False
2
export THUNDRA_AGENT_TRACE_INTEGRATIONS_RDB_DISABLE=False
Copied!

Configure by .env file

Create a file with the .env extension and add the following code snippet into it with your own environment variables.
1
THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY>
2
THUNDRA_AGENT_APPLICATION_NAME=<application_name>
3
THUNDRA_AGENT_APPLICATION_STAGE=<application_stage>
4
THUNDRA_AGENT_APPLICATION_VERSION=<application_version>
5
THUNDRA_AGENT_DEBUG_ENABLE=True
Copied!
For Django, there are two additional variables for database configuration:
1
THUNDRA_AGENT_TRACE_INTEGRATIONS_DJANGO_ORM_DISABLE=False
2
THUNDRA_AGENT_TRACE_INTEGRATIONS_RDB_DISABLE=False
Copied!

Sample Docker Configuration

Simple Django production-ready Docker file:

1
FROM python:3
2
3
# This is the port that Gunicorn uses, so expose it to the outside
4
# world.
5
EXPOSE 8000
6
7
# Don't just add the base code directory, to try to cut down on
8
# rebuild sizes.
9
RUN mkdir /code
10
WORKDIR /code
11
12
# Install all the requirements -- doing things in this order should
13
# reduce the size of redeployments if we don't change dependencies.
14
ADD requirements.txt /code/
15
RUN pip install -r requirements.txt
16
17
# Add the main code directory and point at the start script.
18
ADD . /code
19
CMD ["./start.sh"]
Copied!

Start.sh file

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

Configure environment variable:

1
docker run ... \
2
-e THUNDRA_APIKEY=<YOUR-THUNDRA-API-KEY> \
3
-e THUNDRA_AGENT_APPLICATION_NAME=<YOUR-APP-NAME> \
4
-e THUNDRA_AGENT_APPLICATION_STAGE=dev \
5
-e THUNDRA_AGENT_APPLICATION_VERSION=<YOUR-APP-VERSION> \
6
-e THUNDRA_AGENT_DEBUG_ENABLE=True \
7
...
Copied!

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:
1
docker run ...
Copied!

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:

1
from pathlib import Path
2
from dotenv import load_dotenv
3
4
env_path = Path(<.env file path>).resolve()
5
load_dotenv(dotenv_path=env_path)
6
7
try:
8
import tracepointdebug
9
tracepointdebug.start()
10
except ImportError as e:
11
pass
Copied!

Configure by .env File:

To install environment variables from the configuration file, you should install pathlib and dotenv first.
1
from pathlib import Path
2
from dotenv import load_dotenv
3
4
env_path = Path(<.env file path>).resolve()
5
load_dotenv(dotenv_path=env_path)
6
7
try:
8
import tracepointdebug
9
tracepointdebug.start()
10
except ImportError as e:
11
pass
Copied!
Last modified 4mo ago