mirror of
https://github.com/simonw/datasette.git
synced 2026-09-26 11:54:07 +02:00
execute_write(), execute_write_script() and execute_write_many() were the only Database methods that ran SQL without producing an OpenTelemetry span, so any instance doing writes - which is every instance, since Datasette builds its internal catalog through these methods at startup - showed reads in a trace and nothing else. The same db.system, db.namespace and db.query.text attributes the read path already sets now appear here, with db.query.text going through sql_attribute() so attacker-supplied SQL cannot put an unbounded string on a span. execute_write_many() records the parameter-set count as datasette.param_sets, not datasette.rows_returned. executemany() consumes parameter sets and returns no rows at all, so a rows_returned name would be describing something that does not exist - and a consumer building a "rows written" dashboard on top of it would be charting the wrong number. These spans only cover the event-loop side of a write. The time actually spent waiting on the write queue and executing on the write thread is not attributed yet; that needs context propagation across the thread boundary and lands separately. Writes with block=False are worse still - execute_write_fn returns before the write happens, so the span closes early. Span links fix that later. As with the read path, the existing `with trace(...)` wrappers stay put and the new spans nest inside them, so ?_trace=1 keeps working unchanged - including execute_write_many's `count`, which the old tracer stashes through the context manager's return value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| default_permissions | ||
| publish | ||
| static | ||
| templates | ||
| utils | ||
| views | ||
| __init__.py | ||
| __main__.py | ||
| _pytest_plugin.py | ||
| actor_auth_cookie.py | ||
| app.py | ||
| background_tasks.py | ||
| blob_renderer.py | ||
| cli.py | ||
| column_types.py | ||
| csrf.py | ||
| database.py | ||
| default_actions.py | ||
| default_column_types.py | ||
| default_database_actions.py | ||
| default_debug_menu.py | ||
| default_jump_items.py | ||
| default_magic_parameters.py | ||
| default_query_actions.py | ||
| default_table_actions.py | ||
| events.py | ||
| extras.py | ||
| facets.py | ||
| filters.py | ||
| fixtures.py | ||
| forbidden.py | ||
| handle_exception.py | ||
| hookspecs.py | ||
| inspect.py | ||
| jump.py | ||
| permissions.py | ||
| plugins.py | ||
| renderer.py | ||
| resources.py | ||
| sql_functions.py | ||
| stored_queries.py | ||
| telemetry.py | ||
| template_contexts.py | ||
| tokens.py | ||
| tracer.py | ||
| url_builder.py | ||
| version.py | ||
| write_sql.py | ||