Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### Fixed

- A `[budgets]` section in `tracepanel.toml` (or `[tool.tracepanel.budgets]`)
is the agent's `check`, not an unknown setting.

## 0.17.0 (2026-11-20)

Needs `tracepanel-agent` 0.17.0 (installed with it).
Expand Down
11 changes: 9 additions & 2 deletions src/tracepanel/core/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ class ConfigError(ValueError):


FILES = ("tracepanel.toml", "pyproject.toml")
# Sections of the file that are not the SDK's settings: the agent's `check` reads the budgets.
NOT_SETTINGS = frozenset({"budgets"})


def find_file(start: Path) -> tuple[Path, dict[str, object]] | None:
Expand All @@ -320,15 +322,20 @@ def find_file(start: Path) -> tuple[Path, dict[str, object]] | None:
for directory in (start, *start.parents):
tracepanel_toml = directory / "tracepanel.toml"
if tracepanel_toml.is_file():
return tracepanel_toml, _read_toml(tracepanel_toml)
return tracepanel_toml, _settings(_read_toml(tracepanel_toml))
pyproject = directory / "pyproject.toml"
if pyproject.is_file():
section = _read_toml(pyproject).get("tool", {})
settings = section.get("tracepanel") if isinstance(section, dict) else None
return (pyproject, dict(settings)) if isinstance(settings, dict) else None
return (pyproject, _settings(settings)) if isinstance(settings, dict) else None
return None


def _settings(values: dict[str, object]) -> dict[str, object]:
"""The file's settings, without the sections other tools read there (NOT_SETTINGS)."""
return {name: value for name, value in values.items() if name not in NOT_SETTINGS}


def _read_toml(path: Path) -> dict[str, object]:
try:
return tomllib.loads(path.read_text())
Expand Down
12 changes: 12 additions & 0 deletions tests/core/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@ def test_bad_file_values_name_the_file(project: Path) -> None:
loaded()


def test_the_agents_budgets_in_the_file_are_not_settings(project: Path) -> None:
(project / "tracepanel.toml").write_text('slow_sql_ms = 50\n\n[budgets."GET /api/*"]\nsql_max = 10\n')
(project / "pyproject.toml").write_text("[tool.tracepanel]\n\n[tool.tracepanel.budgets]\nsql_max = 10\n")

assert loaded().slow_sql_ms == 50

(project / "tracepanel.toml").unlink()
conf.reset()

assert loaded().slow_sql_ms == 100 # the default


def test_integrations_can_be_turned_off(project: Path, monkeypatch: pytest.MonkeyPatch) -> None:
(project / "tracepanel.toml").write_text("celery_enabled = false\n")

Expand Down
Loading