Tracepanel

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:

  1. tracepanel.toml, or [tool.tracepanel] in pyproject.toml.
  2. The framework's settings. In Django, that is the TRACEPANEL dict in settings. In Flask, it is app.config["TRACEPANEL"] and the keyword arguments of install(). In FastAPI, Starlette, Falcon and plain ASGI or WSGI apps, it is the keyword arguments of install().
  3. tracepanel.core.conf.configure() in code.
  4. 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.

SettingDefaultWhat it does
enabledfalseWhether 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.
rootthe current directoryThe project's directory. Stack paths are relative to it, and the store lives in it. Django sets it from BASE_DIR.
servicethe name of rootThis project's name on the service map.
widgettrueAdds 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_logtrueLeaves the requests under prefix out of the server's access log: uvicorn, gunicorn, hypercorn, granian, daphne, and the Django and Flask development servers.
dir.tracepanelThe project's store directory, relative to root.
agentautoWhere 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_urlhttp://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_summarytruePrints a line in the terminal after each task run and management command, with a link to its trace.
max_traces2000The number of traces the agent keeps. It deletes older ones.
n_plus_one_threshold3The 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_ms5Tracepanel 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_ms100Tracepanel 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_ms500Tracepanel 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_ms500Tracepanel reports outer transactions longer than this, in milliseconds. They hold their locks until COMMIT.
slow_sql_ms_by_dbnoneslow_sql_ms for one database, by its kind, such as {"snowflake": 3000}. See A limit per database.
long_transaction_ms_by_dbnonelong_transaction_ms for one database, by its kind.
capture_localstrueKeeps the local variables of your project's frames in errors, masked.
capture_mail_bodytrueKeeps the text and HTML of sent emails.
capture_sql_paramstrueKeeps SQL parameter values, so the console can run EXPLAIN. Also keeps the values of MongoDB commands.
user_switchtrueLets the panel log in as another user, from this machine only.
capture_task_argstrueKeeps task arguments and results, masked.
capture_requesttrueKeeps 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_bodytrueKeeps 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_kb64How much of a body Tracepanel keeps, in KiB. A longer one is cut there and marked as cut.
capture_llm_contentfalseKeeps the messages of LLM calls, sent and received, masked and cut at max_body_kb. See LLM calls.
llm_pricesnoneA 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_settingstrueSends the app's settings to the console's app page, masked: Django's settings and Flask's app.config.
capture_template_contexttrueKeeps the context each template is rendered with, masked.
profilefalseProfiles 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_memoryfalseCounts 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_enabledtrueWhether anything can be profiled. false turns off the setting, the header and the cookie alike.
profile_interval_ms1How often the profiler samples a profiled trace's stack, in milliseconds. Only a profiled trace pays for it.
ignore_paths/health*, /static/*, /media/*, /favicon.icoGlob patterns on the request path. Tracepanel doesn't trace matching requests.
ignore_tasksnoneGlob patterns on the task name, such as celery.backend_cleanup. Tracepanel doesn't trace matching tasks.
ignore_loggersnoneLoggers whose records Tracepanel leaves out, with their children. Tracepanel always leaves out its own logs and SQL echo.
ignore_signalspre_init, post_init, class_preparedDjango 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_commandsservers, shells and workersManagement 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=3000

This 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 = 20000

Without 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:

LimitValueIssue
queue_wait_ms1 squeue-wait: a task waited longer than this in its queue before a worker took it.
large_result_rows1000 rowslarge-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.

SettingIntegration
anthropic_enabledAnthropic's SDK
boto_enabledAWS calls through botocore: boto3 and aiobotocore
celery_enabledCelery
channels_enabledDjango Channels
dbapi_enabledDatabase drivers used without an ORM
devtools_enabledpython-devtools' debug() as dumps
django_q_enableddjango-q2
django_tasks_enabledDjango Tasks
dramatiq_enabledDramatiq
drf_enabledDjango REST framework
faststream_enabledFastStream
graphene_enabledGraphene, through graphene-django's GraphQLView
http_clients_enabledOutgoing HTTP calls
huey_enabledHuey
jinja_enabledJinja templates
logging_enabledLog records from logging
migrations_enabledDjango's migrate
mongodb_enabledMongoDB
ninja_enabledDjango Ninja
openai_enabledOpenAI's SDK
otel_enabledOpenTelemetry
redis_enabledRedis
rq_enabledRQ
signals_enabledDjango signals
sqlalchemy_enabledSQLAlchemy
storage_enabledDjango's file storages and collectstatic
strawberry_enabledStrawberry
taskiq_enabledTaskiq

See Integrations for what each one records.

On this page