Skip to content

refactor(telemetry): convert is_tty metric to span tag#499

Merged
betegon merged 1 commit intomainfrom
refactor/is-tty-metric-to-tag
Mar 20, 2026
Merged

refactor(telemetry): convert is_tty metric to span tag#499
betegon merged 1 commit intomainfrom
refactor/is-tty-metric-to-tag

Conversation

@betegon
Copy link
Member

@betegon betegon commented Mar 20, 2026

Summary

Replaces the cli.invocation counter metric with a Sentry.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

  • Swap Sentry.metrics.count("cli.invocation", ...) for Sentry.setTag("is_tty", ...)
  • Remove the invocationCounted guard (tags are idempotent on re-init)

Test plan

  • bun run typecheck — passes
  • bun test test/lib/telemetry.test.ts — all 96 tests pass
  • Run sentry issue list in a terminal and via pipe, confirm is_tty tag appears on transactions in Sentry Discover

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>
@github-actions
Copy link
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (telemetry) Track TTY vs non-TTY invocations via metric by betegon in #482
  • Dynamic cache-backed shell completions with fuzzy matching by BYK in #465

Bug Fixes 🐛

  • (project) Fallback to org listing when bare slug matches an organization by betegon in #475
  • Add 400 suggestions to org-all issue list path (CLI-BY) by BYK in #497
  • Lowercase project slug in issue arg parsing (CLI-C8) by BYK in #496
  • Enrich short ID 404 with org context and suggestions (CLI-A1) by BYK in #494
  • Suggest similar projects when project not found in org (CLI-C0) by BYK in #493
  • Event 404 hint should suggest different project, not repeat failing command by BYK in #492
  • Enrich event 404 errors with retention and format suggestions (CLI-6F) by BYK in #491
  • Add actionable suggestions for 400 Bad Request on issue list (CLI-BM, CLI-7B) by BYK in #489
  • Detect issue short IDs passed to issue list (CLI-C3) by BYK in #488
  • Add Glob.match() polyfill + improve auto-detect diagnostics (CLI-7T) by BYK in #487
  • Add org-slug pre-check to dispatchOrgScopedList (CLI-9A) by BYK in #485

Internal Changes 🔧

  • (issue) Skip getProject round-trip in project-search resolution by betegon in #473
  • (resolve) Carry project data through resolution to eliminate redundant getProject calls by BYK in #486
  • (telemetry) Convert is_tty metric to span tag by betegon in #499
  • HTTP latency optimizations — diagnostics, cache warming, concurrency limits by BYK in #490
  • Switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) by BYK in #474
  • Regenerate skill files by github-actions[bot] in b7b240ec

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 50.00%. Project has 1056 uncovered lines.
✅ Project coverage is 95.72%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
telemetry.ts 91.34% ⚠️ 40 Missing
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

@betegon betegon marked this pull request as ready for review March 20, 2026 09:39
@betegon betegon merged commit 8236325 into main Mar 20, 2026
22 checks passed
@betegon betegon deleted the refactor/is-tty-metric-to-tag branch March 20, 2026 09:41
});
}
// Tag whether running in an interactive terminal or agent/CI environment
Sentry.setTag("is_tty", !!process.stdout.isTTY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protip: Boolean(process.stdout.isTTY) next time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants