Repository navigation
Conversation
Declares every span, metric and attribute in telemetry_registry.py using Datasette 1.0a41's plugin telemetry kit. No instrumentation yet. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds an apps.query span plus apps.queries / apps.query.duration metrics around datasette.query() and datasette.storedQuery() calls, and tags request spans on app routes with apps.app_id. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
apps.changes counts creates, edits, deletes and pins by channel (web or agent). Agent tools set apps.app_id and apps.tool.result on the current span, which is datasette-agent's execute_tool span when it has telemetry. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
apps.debug.runs counts terminal debug runs by outcome, with wall-clock and browser-reported script durations. Lazily expired jobs are counted separately, and the debug frame and query routes tag their request spans with the job and app IDs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Checks that everything emitted is registered and everything registered is emitted, plants sentinel values to prove app HTML, SQL parameters, debug scripts and tokens never reach telemetry, and generates the README's telemetry reference from the registry. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
asg017
added this pull request to stack #42
September 28, 2026 21:05
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Claude-generated PR description
Adds OpenTelemetry spans and metrics to datasette-apps using Datasette 1.0a41's plugin telemetry kit (
datasette.telemetry,datasette.telemetry_registry,datasette.telemetry_testing). This is stacked on #39 (Require Datasette 1.0a41); rebase ontomainonce that merges.Scope
datasette_apps, prefixapps.*, noschema_url. With no OpenTelemetry SDK installed, everything is a no-op. We add one span of our own (apps.query). Everywhere else we add attributes to core's request spans and to the current agent tool span, rather than re-wrapping work core already traces.Commits (one per ticket)
telemetry_registry.py, which declares every span, metric and attribute, andtelemetry.py, with helpers that never import the SDK. Also adds atests/conftest.pywired to the kit's fixtures and static registry tests.opentelemetry-apibecomes a runtime dependency;opentelemetry-sdkis dev-only.app_queryanddebug_querynow share one code path, wrapped in anapps.queryspan.apps.queriescounter andapps.query.durationhistogram, with outcomeok/not_allowed/denied/failed/invalid/not_found/error.apps.app_idon the request spans of the nine app routes.datasette.clientrequests now carry W3C trace headers, so core's internal request span nests underapps.query. This works around datasette#2969;trace_headers()can go once the minimum Datasette version includes the fix.apps.changescounts create / edit / delete / pin / unpin, split byweb/agent, and only after a successful write.apps.tool.resulton the current span, andapps.app_idonly once the app is known to exist. Model-supplied IDs are never recorded unverified.apps.debug.runsby outcome, plus run and script duration histograms, andapps.debug.jobs.expired, which counts only rows actually flipped./frameand/queryrequest spans.app_debugexecutes twice per logical run (suspend, then resume). The outcome is recorded exactly once, on the terminal execution. Tests cover this with both a fake context and datasette-agent's real one.scripts/telemetry-doc.py), with a pytest freshness test. CI needs no workflow changes.Never recorded
App HTML, names and descriptions; SQL text or parameter values; stored query names; debug JS, results, logs or errors; CSP origins; actor or conversation IDs; frame, channel and bridge tokens; exception messages.
apps.app_id,apps.debug.job_idanddb.namespacego on spans only, never on metrics.Notes
errorbut not fixed here: App query endpoints return 500 on non-object JSON body #40.apps.tool.resultandapps.debug.runsare left unset when an exception escapes a tool. A datasette-agent version with telemetry recordserror.typeon its own span. The released datasette-agent 0.4a0 has no telemetry, so our tool attributes land on whatever span is current.Testing
pytest --ignore=tests/test_playwright.py: 284 passed, 1 skipped (skipped: an integration test gated ondatasette_agent.telemetry). Also passes on Python 3.10.pytest tests/test_playwright.py: 12 passed.scripts/telemetry-doc.py --check: clean.🤖 Generated with Claude Code