Configuration
Where the Python SDK reads its settings from, which source wins, and every setting with its default.
The Python SDK works with no settings. Every setting has a default, and you change only the ones you need.
Where settings come from
Tracepanel reads settings from these places. A later place wins over an earlier one:
tracepanel.toml, or[tool.tracepanel]inpyproject.toml.- The framework's settings. In Django, that is the
TRACEPANELdict in settings. In Flask, it isapp.config["TRACEPANEL"]and the keyword arguments ofinstall(). In FastAPI, Starlette, Falcon and plain ASGI or WSGI apps, it is the keyword arguments ofinstall(). tracepanel.core.conf.configure()in code.TRACEPANEL_<NAME>environment variables.
Tracepanel looks for tracepanel.toml and pyproject.toml from the project's
directory upward. It stops at the first tracepanel.toml, or at the first
pyproject.toml, with or without a [tool.tracepanel] section.
# pyproject.toml
[tool.tracepanel]
slow_sql_ms = 50
n_plus_one_threshold = 5
ignore_paths = ["/health*", "/static/*"]tracepanel run --set name=value sets the TRACEPANEL_<NAME> variable for
one run. See Command line.
Tracepanel checks every value against its setting's type. An unknown name or a wrong type raises an error, and the error names the place the value came from.
Check the settings in effect
tracepanel config prints every setting, its value and the place that set it.
Then it prints each integration and its state:
slow_sql_ms 200 pyproject.toml [tool.tracepanel]
capture_locals false env TRACEPANEL_CAPTURE_LOCALS
...
integrations
logging on
Database drivers on
HTTP clients on
Redis off: redis_enabled
MongoDB off: not installed
Celery on
DRF on (Django apps only)tracepanel config runs outside your app, so it reads the files, the
variables and nothing else. It doesn't read Django's settings: the
TRACEPANEL dict, DEBUG and BASE_DIR don't show in its output. Nor does it
see the keyword arguments of install() or configure() in your code.
Settings
Each setting has a variable of its own: TRACEPANEL_ and the setting's name
in capitals, such as TRACEPANEL_PROFILE_MEMORY=1 or
TRACEPANEL_CAPTURE_LLM_CONTENT=true.
| Setting | Default | What it does |
|---|---|---|
enabled | false | Whether Tracepanel records anything. The framework decides by default: DEBUG in Django, debug mode in FastAPI, Starlette, Flask and plain ASGI or WSGI apps. Falcon stays off. TRACEPANEL_ENABLED, which tracepanel run sets, wins over it. |
root | the current directory | The project's directory. Stack paths are relative to it, and the store lives in it. Django sets it from BASE_DIR. |
service | the name of root | This project's name on the service map. |
widget | true | Adds the panel's script to HTML responses. |
prefix | /__tracepanel__/ | The URL prefix of the console, the panel's script and the JSON API. |
quiet_access_log | true | Leaves the requests under prefix out of the server's access log: uvicorn, gunicorn, hypercorn, granian, daphne, and the Django and Flask development servers. |
dir | .tracepanel | The project's store directory, relative to root. |
agent | auto | Where traces go. auto sends them to the project's agent and starts it on demand. An address such as tcp:host.docker.internal:7701 sends them to an agent elsewhere. off keeps no traces. |
console_url | http://127.0.0.1:8765/ | The console of an agent set by address in agent. Terminal lines link here when the project has no agent of its own. |
terminal_summary | true | Prints a line in the terminal after each task run and management command, with a link to its trace. |
max_traces | 2000 | The number of traces the agent keeps. It deletes older ones. |
n_plus_one_threshold | 3 | The number of similar queries with different parameters that Tracepanel reports as an N+1. The same goes for MongoDB commands, Redis commands and cache calls. |
n_plus_one_min_ms | 5 | Tracepanel reports repeated Redis commands and cache calls only when they take this long together, in milliseconds. An in-memory store answers in a fraction of a millisecond. |
slow_sql_ms | 100 | Tracepanel reports queries slower than this, in milliseconds, as slow SQL. A MongoDB command slower than this is a slow call, with the index it needs. |
slow_http_ms | 500 | Tracepanel reports outgoing HTTP calls slower than this, in milliseconds, as slow. The same goes for a storage call over the network, such as S3's. |
long_transaction_ms | 500 | Tracepanel reports outer transactions longer than this, in milliseconds. They hold their locks until COMMIT. |
slow_sql_ms_by_db | none | slow_sql_ms for one database, by its kind, such as {"snowflake": 3000}. See A limit per database. |
long_transaction_ms_by_db | none | long_transaction_ms for one database, by its kind. |
capture_locals | true | Keeps the local variables of your project's frames in errors, masked. |
capture_mail_body | true | Keeps the text and HTML of sent emails. |
capture_sql_params | true | Keeps SQL parameter values, so the console can run EXPLAIN. Also keeps the values of MongoDB commands. |
user_switch | true | Lets the panel log in as another user, from this machine only. |
capture_task_args | true | Keeps task arguments and results, masked. |
capture_request | true | Keeps what each request carried: its headers, query, cookies, the body as far as the app read it, its session and the response's headers, masked. |
capture_body | true | Keeps the bodies of requests and of their responses: JSON and forms, masked, and text. A response's page, scripts and binary content are kept by their size only, and a stream not at all. |
max_body_kb | 64 | How much of a body Tracepanel keeps, in KiB. A longer one is cut there and marked as cut. |
capture_llm_content | false | Keeps the messages of LLM calls, sent and received, masked and cut at max_body_kb. See LLM calls. |
llm_prices | none | A JSON file of LLM prices, relative to root, in the shape of the agent's llm-prices.json. The agent this process starts estimates costs with it, over its own prices. Without it, the agent reads llm-prices.json in the store's directory, if there is one. |
capture_settings | true | Sends the app's settings to the console's app page, masked: Django's settings and Flask's app.config. |
capture_template_context | true | Keeps the context each template is rendered with, masked. |
profile | false | Profiles every trace. Without it, a request is profiled when it carries the panel's tracepanel_profile cookie or an X-Tracepanel-Profile header, set to 1 for time or memory for time and memory. |
profile_memory | false | Counts the memory of every profiled trace, not only of a request that asks with memory. It slows the whole process down while a trace is counted. |
profile_enabled | true | Whether anything can be profiled. false turns off the setting, the header and the cookie alike. |
profile_interval_ms | 1 | How often the profiler samples a profiled trace's stack, in milliseconds. Only a profiled trace pays for it. |
ignore_paths | /health*, /static/*, /media/*, /favicon.ico | Glob patterns on the request path. Tracepanel doesn't trace matching requests. |
ignore_tasks | none | Glob patterns on the task name, such as celery.backend_cleanup. Tracepanel doesn't trace matching tasks. |
ignore_loggers | none | Loggers whose records Tracepanel leaves out, with their children. Tracepanel always leaves out its own logs and SQL echo. |
ignore_signals | pre_init, post_init, class_prepared | Django signals that Tracepanel leaves out, as glob patterns on the name, such as post_save, or the dotted path, such as shop.signals.order_placed. The defaults fire for every object a query loads and every model class built. |
ignore_commands | servers, shells and workers | Management commands that Tracepanel doesn't trace. The defaults are runserver, runserver_plus, shell, shell_plus, dbshell, test, testserver, db_worker, rqworker, rqscheduler, rundramatiq, run_huey, qcluster, qmonitor and runworker. A worker's tasks still become traces of their own. |
A limit per database
The slow query and long transaction limits can be set per database too, by
its kind, its db.system, such as postgresql or snowflake. In a variable,
the kinds follow the limit for every database:
TRACEPANEL_SLOW_SQL_MS=100,snowflake=3000This holds every database to 100 ms, and Snowflake to 3 s. In a file or in Django's settings, the limits per database are a mapping of their own:
[tool.tracepanel.slow_sql_ms_by_db]
snowflake = 3000
[tool.tracepanel.long_transaction_ms_by_db]
snowflake = 20000Without one, the agent holds an analytical warehouse, such as Snowflake, BigQuery, Databricks, Redshift or ClickHouse, to 2 s per query and 10 s per transaction. A database's own limit wins over that and over the limit for every database.
Fixed thresholds
The agent finds two more issues with limits that you can't change from the Python SDK:
| Limit | Value | Issue |
|---|---|---|
queue_wait_ms | 1 s | queue-wait: a task waited longer than this in its queue before a worker took it. |
large_result_rows | 1000 rows | large-result: a SELECT with no LIMIT returned this many rows or more. |
Integrations
Each integration patches its library when your app first imports it.
Tracepanel doesn't load a library your app never imports. Set an
integration's setting to false to leave the library unpatched, in a file or
with its variable, such as TRACEPANEL_BOTO_ENABLED=false. Tracepanel reads
these settings at startup. All of them default to true.
| Setting | Integration |
|---|---|
anthropic_enabled | Anthropic's SDK |
boto_enabled | AWS calls through botocore: boto3 and aiobotocore |
celery_enabled | Celery |
channels_enabled | Django Channels |
dbapi_enabled | Database drivers used without an ORM |
devtools_enabled | python-devtools' debug() as dumps |
django_q_enabled | django-q2 |
django_tasks_enabled | Django Tasks |
dramatiq_enabled | Dramatiq |
drf_enabled | Django REST framework |
faststream_enabled | FastStream |
graphene_enabled | Graphene, through graphene-django's GraphQLView |
http_clients_enabled | Outgoing HTTP calls |
huey_enabled | Huey |
jinja_enabled | Jinja templates |
logging_enabled | Log records from logging |
migrations_enabled | Django's migrate |
mongodb_enabled | MongoDB |
ninja_enabled | Django Ninja |
openai_enabled | OpenAI's SDK |
otel_enabled | OpenTelemetry |
redis_enabled | Redis |
rq_enabled | RQ |
signals_enabled | Django signals |
sqlalchemy_enabled | SQLAlchemy |
storage_enabled | Django's file storages and collectstatic |
strawberry_enabled | Strawberry |
taskiq_enabled | Taskiq |
See Integrations for what each one records.