datasette/datasette
Alex Garcia e2543c59b8 Trace callback-style calls: execute_fn, execute_write_fn, execute_isolated_fn
The database instrumentation covered the four SQL-string entry points but
not the callback entry points, which are the documented way for plugins to
run arbitrary SQL - so the JSON write API's inserts and deletes, the
startup catalog scan, and every plugin built on execute_fn/execute_write_fn
were invisible to a trace, or worse, showed orphan-looking db.write.* spans
with no db.query above them.

Each callback method now opens the same db.query CLIENT span as its
SQL-string sibling, carrying a new optional datasette.callback attribute
(the callable's qualified name, captured before _wrap_fn_with_hooks() can
rename it) in place of db.query.text, which is now marked optional. A bare
execute_fn() also wraps the callback in a db.query.execute child, so the
"gap between the spans is thread-wait" story holds for plugin callbacks
too. No db.operation.name: there is no statement to take a keyword from,
and the registry says that attribute is omitted rather than guessed.

The previous bodies move to private _execute_fn()/_execute_write_fn() and
the SQL-string methods call those, so an execute() emits exactly the spans
it did before - pinned by test_execute_does_not_double_wrap. Database's own
introspection helpers stay on the public method deliberately: they are real
SQLite round trips, which lifts a table page from ~58 to ~100 (no-op) spans.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012U7coQfVu8nK2R4q2mCULA
2026-09-14 09:04:12 -07:00
..
default_permissions Deny SQLite statistics table access through a default hook 2026-09-10 16:52:25 -07:00
publish Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
static Use .textContent for column names in column chooser 2026-09-08 10:48:19 -07:00
templates Remove JSON syntax highlighting 2026-09-08 10:48:19 -07:00
utils Migrate from httpx to httpx2, closes #2879 2026-09-10 19:44:49 -07:00
views Make db.query spans match OpenTelemetry semantic conventions 2026-09-14 08:55:45 -07:00
__init__.py Merge remote-tracking branch 'origin/main' into claude/json-api-docs-1-0-review-a3e83u 2026-07-06 22:25:27 +00:00
__main__.py Add support for running datasette as a module (#556) 2019-07-11 09:07:44 -07:00
_pytest_plugin.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
actor_auth_cookie.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
app.py Name every span and attribute once, in a registry the docs are built from 2026-09-14 08:55:45 -07:00
blob_renderer.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
cli.py Run startup via ASGI lifespan instead of waiting for the first request (#2887) 2026-09-01 09:39:25 -07:00
column_types.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
csrf.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
database.py Trace callback-style calls: execute_fn, execute_write_fn, execute_isolated_fn 2026-09-14 09:04:12 -07:00
default_actions.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
default_column_types.py Normalize URL column schemes consistently 2026-09-08 21:16:35 -07:00
default_database_actions.py No execute-write on immutable databases 2026-05-25 12:46:21 -07:00
default_debug_menu.py Autocomplete widget and /-/debug/autocomplete test page 2026-06-13 22:59:37 -07:00
default_jump_items.py Remove source and source_key columns from JumpSQL 2026-05-23 20:41:32 -07:00
default_magic_parameters.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
default_query_actions.py Web UI to edit and delete stored queries (#2764) 2026-06-08 20:19:47 -07:00
default_table_actions.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
events.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
extras.py Return 400 for unknown _extra names on data formats 2026-07-04 16:16:02 +00:00
facets.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
filters.py Authorize configured full-text search targets 2026-09-08 21:16:35 -07:00
fixtures.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
forbidden.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
handle_exception.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
hookspecs.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
inspect.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
jump.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
permissions.py Match table permission identities using SQLite case semantics 2026-09-09 08:39:03 -07:00
plugins.py Deny SQLite statistics table access through a default hook 2026-09-10 16:52:25 -07:00
renderer.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
resources.py Match table permission identities using SQLite case semantics 2026-09-09 08:39:03 -07:00
sql_functions.py _search= queries now correctly escaped, fixes #651 2019-12-29 18:48:30 +00:00
stored_queries.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
telemetry.py Trace callback-style calls: execute_fn, execute_write_fn, execute_isolated_fn 2026-09-14 09:04:12 -07:00
telemetry_registry.py Trace callback-style calls: execute_fn, execute_write_fn, execute_isolated_fn 2026-09-14 09:04:12 -07:00
template_contexts.py Clarify template context metadata names 2026-06-23 11:30:30 -07:00
tokens.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
tracer.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
url_builder.py Upgrade to ruff>=0.16.0 (#2857) 2026-07-25 15:47:08 -07:00
version.py Release 1.0a39 2026-09-10 16:52:52 -07:00
write_sql.py Reject untrusted table-valued PRAGMA reads 2026-09-08 21:16:35 -07:00