Repository navigation
feat(telemetry): opt-in OpenTelemetry traces and metrics - #40
Merged
Merged
Conversation
Off by default and only on when an admin turns it on (Settings, the setup wizard's new last step, or LENS_TELEMETRY=on in .env; LENS_TELEMETRY=off keeps it off). Sent only to the OTLP/HTTP endpoint that is set; there is no built-in destination. - Traces: API requests by route template, jobs and each step, routines and their actions, workflow runs, and model calls (GenAI conventions) - Metrics: request, step and model-call durations, job/routine/workflow outcomes, tokens, and estimated cost from per-model prices - No personal content: no paths, queries, prompts, answers, transcript text, file names, titles, people, hosts or error messages - Settings shows on/off, where it sends and the last exports, and can send a test span; every process follows changes without a restart Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CFYD76r8LUcnfTYKBwRfPn
Owner
Author
|
CI is red here, but none of the jobs ran. FastAPI (embedded SurrealDB), Next.js, pre-commit and Conventional Commit title all failed within about 5 seconds, with no runner assigned and no logs (job logs return 404). Every other branch shows the same thing right now, including dependabot PR #36. So this is the account's GitHub-hosted Actions minutes, not this PR's code. The fix in progress is #27, which moves the jobs to the self-hosted runner. It is still a draft, another thread owns it, and it depends on that runner being online. I haven't ported it into this PR because that would tie this PR to an unmerged runner setup. Once #27 merges, I'll bring main in and let CI run here. Checked locally on this commit:
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SNbRrpHTCqLewRKdkmd45X
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SNbRrpHTCqLewRKdkmd45X
4 of 8 tasks
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.
Requested by Adeel · project thread
Description
Before: Lens had no telemetry at all, so there was no way to see slow requests, step timings, job failures, or what model calls cost.
After: an admin can opt in under Settings → Telemetry, in the setup wizard's new last step, or with
LENS_TELEMETRY=onplusLENS_TELEMETRY_ENDPOINTin .env. Lens then sends OpenTelemetry traces and metrics over OTLP/HTTP to that endpoint only. It is off by default, has no built-in destination, andLENS_TELEMETRY=offkeeps it off whatever Settings say.lens.llm.costin USD. Cost comes from per-model prices set in Settings; the AI assistant's prices count for the configured model.lens worker/lens watchpick up changes without a restart, and turning it off never blocks a request on a slow collector.How: a new
app/domain/telemetry.pyimports the OpenTelemetry SDK only while telemetry is on and uses its own providers, not the global ones. It is applied wheneversettings.Settings.current()rebuilds. A pure ASGI middleware sits innermost so it can read the matched route. Thellm.pyandanalyze._llmcalls are wrapped. Docs are indocs/telemetry.md, including a sample collector setup.Motivation and Context
Telemetry backlog item. The feature plan requires telemetry to be opt-in only.
Screenshots (if appropriate):
Checked in a browser against a local fake collector: the wizard's Telemetry step (off by default, endpoint and test span when on) and Settings → Telemetry showing "On: sending to …".
Steps to reproduce (if appropriate):
docs/telemetry.md.Types of changes
!in the title)Checklist:
make hookschecks it on commit).tests/api/test_telemetry.pyruns against an in-process OTLP collector; the setup wizard and settings model have Jest tests. The full backend suite passes on embedded SurrealDB and on a SurrealDB 3.2.4 server, excepttest_office_and_text_files_become_documents, which also fails on main in this sandbox because of its LibreOffice.docs/accordingly.## UnreleasedinCHANGELOG.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01CFYD76r8LUcnfTYKBwRfPn
Generated by Claude Code