Skip to content

Improve telemetry for debugging#206

Merged
matin merged 5 commits intomainfrom
add-version-to-telemetry
Mar 18, 2026
Merged

Improve telemetry for debugging#206
matin merged 5 commits intomainfrom
add-version-to-telemetry

Conversation

@matin
Copy link
Copy Markdown
Owner

@matin matin commented Mar 18, 2026

Summary

Improvements to make it easier to diagnose auth issues from logfire:

  • Add garth_version to every telemetry span so we can tell which version a user is running without asking
  • Print session ID to stdout on import (no logging setup required)
  • Update docs and auth issue template to reference the auto-printed session ID
  • Bump version to 0.7.2

Would have helped with the 0.7.0 → 0.7.1 audience bug — we could have immediately filtered logfire by version to see who was still on the broken release.

Test plan

  • 163 tests pass
  • CodeRabbit review clean

Closes #205

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Updated package version to 0.7.2
    • Session ID output now goes to standard output (stdout) instead of logging
  • New Features

    • Telemetry payloads now include package version information for better tracking
  • Tests

    • Added tests to validate version information is captured in telemetry
  • Documentation

    • Updated telemetry docs and issue template to reflect session ID output and reporting guidance

matin and others added 2 commits March 18, 2026 01:45
Add garth_version to every telemetry log entry so we can identify
which version a user is running from logfire without asking them.

Closes #205

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Adds the package version to telemetry payloads by importing __version__ and including garth_version in telemetry data. Bumps package version from 0.7.1 to 0.7.2. Tests and documentation/telemetry output formatting updated to reflect this change.

Changes

Cohort / File(s) Summary
Telemetry implementation & version
src/garth/telemetry.py, src/garth/version.py
Import __version__ and add garth_version to the telemetry _response_hook() payload; update __version__ from "0.7.1" to "0.7.2".
Tests
tests/test_telemetry.py
Add assertions that captured telemetry contains garth_version equal to __version__.
Telemetry output change
src/garth/http.py
Replace logger.info with a print for emitting the telemetry session ID to stdout when telemetry is enabled.
Docs & issue template
docs/telemetry.md, .github/ISSUE_TEMPLATE/auth-issue.yml
Adjust examples and prose to indicate session_id is printed to stdout; remove embedded Python print snippet and update example formatting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Improve telemetry for debugging' is vague and generic, using non-descriptive language that doesn't clearly convey the specific change of adding garth version to telemetry spans. Revise the title to be more specific about the main change, such as 'Add garth version to telemetry spans' or 'Include package version in telemetry data'.
Out of Scope Changes check ❓ Inconclusive The PR includes changes to session ID logging (logger.info to print) and documentation updates that, while related to telemetry, extend beyond the core requirement of adding garth_version to telemetry spans. Clarify whether the logger.info to print() change and documentation updates were part of issue #205 scope or represent separate enhancements; consider separating if not explicitly required.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #205: adding garth_version field to telemetry data in Telemetry._response_hook() and including the package version from version, enabling version identification in Logfire.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-version-to-telemetry
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (2f4b5bd) to head (b42ec0f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #206   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files          68       68           
  Lines        3543     3547    +4     
=======================================
+ Hits         3542     3546    +4     
  Misses          1        1           
Flag Coverage Δ
unittests 99.97% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Users should see their session ID without configuring logging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/test_telemetry.py (1)

95-95: Strengthen version assertions to validate the exact source value.

These assertions currently only check presence/truthiness. Assert equality to garth.version.__version__ so tests fail if the payload value drifts from the package version.

Proposed test hardening
+from garth.version import __version__
@@
-    assert "garth_version" in captured_data[0]
+    assert captured_data[0]["garth_version"] == __version__
@@
-    assert data["garth_version"]
+    assert data["garth_version"] == __version__

Also applies to: 185-185

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_telemetry.py` at line 95, The test currently only asserts presence
of "garth_version" in captured_data[0]; change the assertion to compare the
payload value to the package version by asserting
captured_data[0]["garth_version"] == garth.version.__version__ (and likewise at
the other occurrence around line 185), ensuring you import or reference
garth.version.__version__ so the test fails if the telemetry value drifts from
the actual package version.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/test_telemetry.py`:
- Line 95: The test currently only asserts presence of "garth_version" in
captured_data[0]; change the assertion to compare the payload value to the
package version by asserting captured_data[0]["garth_version"] ==
garth.version.__version__ (and likewise at the other occurrence around line
185), ensuring you import or reference garth.version.__version__ so the test
fails if the telemetry value drifts from the actual package version.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d3c6d12-9f7a-4f1f-b9e8-1a9ae22617b6

📥 Commits

Reviewing files that changed from the base of the PR and between 2f4b5bd and ebca3b8.

📒 Files selected for processing (3)
  • src/garth/telemetry.py
  • src/garth/version.py
  • tests/test_telemetry.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matin matin changed the title Include garth version in telemetry spans Improve telemetry for debugging Mar 18, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matin matin merged commit f2c61ff into main Mar 18, 2026
25 checks passed
@matin matin deleted the add-version-to-telemetry branch March 18, 2026 08:56
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.

Include garth version in telemetry spans

1 participant