refactor(telemetry): convert is_tty metric to span tag#499
Merged
Conversation
Replace the `cli.invocation` counter metric with a `Sentry.setTag("is_tty", ...)`
so the TTY/non-TTY signal is attached to every transaction — searchable in
Discover and usable as a grouping dimension alongside command, latency, and errors.
Also removes the `invocationCounted` guard since `setTag` is idempotent on
re-init (auto-login retry).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 50.00%. Project has 1056 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.72% 95.72% —%
==========================================
Files 180 180 —
Lines 24686 24680 -6
Branches 0 0 —
==========================================
+ Hits 23630 23624 -6
- Misses 1056 1056 —
- Partials 0 0 —Generated by Codecov Action |
BYK
reviewed
Mar 20, 2026
| }); | ||
| } | ||
| // Tag whether running in an interactive terminal or agent/CI environment | ||
| Sentry.setTag("is_tty", !!process.stdout.isTTY); |
Member
There was a problem hiding this comment.
Protip: Boolean(process.stdout.isTTY) next time :)
This was referenced Mar 20, 2026
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.
Summary
Replaces the
cli.invocationcounter metric with aSentry.setTag("is_tty", ...)so the TTY/non-TTY signal lives on every transaction instead of in the separate Metrics dashboard. This lets us filter and group any Discover query by terminal type — correlating it with command, latency, errors, etc.Changes
Sentry.metrics.count("cli.invocation", ...)forSentry.setTag("is_tty", ...)invocationCountedguard (tags are idempotent on re-init)Test plan
bun run typecheck— passesbun test test/lib/telemetry.test.ts— all 96 tests passsentry issue listin a terminal and via pipe, confirmis_ttytag appears on transactions in Sentry Discover