Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
asg017
force-pushed
the
asg017/otel-v2-purpose-metric
branch
from
September 25, 2026 18:22
0838b74 to
1873eb9
Compare
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
Stacked on the
datasette_llm.promptspan PR (branchasg017/otel-v2).This PR adds one OpenTelemetry histogram,
datasette_llm.token.usage(unit{token}), so operators can chart token spend per feature. Its attributes are bounded:datasette_llm.purpose: the declared purpose, or"none"gen_ai.token.type:inputoroutputgen_ai.request.modelllm's own metrics (in a separate PR) key by model and provider. Only datasette-llm knows the purpose.
How
usage_recorder(purpose, model_id)callback is registered withPromptResult.on_response_doneat the same three places the span is opened: chain, conversation prompt and model prompt. It recordsresponse.input_tokens/output_tokenswhenever they are not None. It never forces a response.Tests
A session-scoped
InMemoryMetricReaderwith delta temporality covers:"none"model.promptandconversation().promptrecord one point per token typeuv run pytest: 67 passed.🤖 Generated with Claude Code