feat(telemetry): capture error message on failed CLI runs #21

Merged
starkSV merged 1 commit from feat/telemetry-error-field into main 2026-07-08 12:36:26 +05:30
starkSV commented 2026-07-08 12:35:57 +05:30 (Migrated from github.com)

Summary

  • Adds an error field to the CLI telemetry payload, populated (truncated) whenever a CLI run fails
  • Backend records it in a new msdl:telemetry:errors Redis hash and exposes it via /metrics
  • Backward compatible: old CLI clients omit the field, backend treats it as empty

Why

  • Production telemetry showed failed CLI runs with no way to diagnose the cause
  • This closes that gap for future failures

Test plan

  • Both cli and backend build clean
  • Verified CLI error path still exits 1 and prints error to stderr
  • After merge: redeploy backend, tag cli/v0.3.2, submit winget PR

Summary by CodeRabbit

  • New Features

    • Telemetry now includes error details for failed actions, giving a clearer view of what went wrong.
    • Error reporting is size-limited to keep telemetry payloads compact.
  • Bug Fixes

    • Telemetry summaries now track error breakdowns in aggregated reporting, improving visibility into failure patterns.
## Summary - Adds an error field to the CLI telemetry payload, populated (truncated) whenever a CLI run fails - Backend records it in a new msdl:telemetry:errors Redis hash and exposes it via /metrics - Backward compatible: old CLI clients omit the field, backend treats it as empty ## Why - Production telemetry showed failed CLI runs with no way to diagnose the cause - This closes that gap for future failures ## Test plan - Both cli and backend build clean - Verified CLI error path still exits 1 and prints error to stderr - After merge: redeploy backend, tag cli/v0.3.2, submit winget PR <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Telemetry now includes error details for failed actions, giving a clearer view of what went wrong. * Error reporting is size-limited to keep telemetry payloads compact. * **Bug Fixes** * Telemetry summaries now track error breakdowns in aggregated reporting, improving visibility into failure patterns. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2026-07-08 12:36:25 +05:30 (Migrated from github.com)

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d84088de-1517-4e12-9e08-acee21d66019

📥 Commits

Reviewing files that changed from the base of the PR and between 8258bd139d and 8ab322038b.

📒 Files selected for processing (2)
  • backend/main.go
  • cli/main.go

📝 Walkthrough

Walkthrough

This PR adds error tracking to the telemetry system. The CLI now truncates error messages to 150 characters and includes them in telemetry payloads. The backend accepts this new Error field, increments a Redis-based error counter on failed telemetry events, and includes error aggregates when loading telemetry data.

Changes

Telemetry Error Tracking

Layer / File(s) Summary
CLI error capture and truncation
cli/main.go
Adds an Error field to cliTelemetryPayload and a truncateError helper that caps error text at 150 characters; wires truncateError(err) into the telemetry event sent via sendTelemetry.
Backend error ingestion and aggregation
backend/main.go
Adds an Error field to telemetryPayload; in handleTelemetry, increments the msdl:telemetry:errors Redis hash when a failed event includes a valid (≤200 char) error; loadTelemetryFromRedis now also loads this hash into aggregated telemetry output.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Backend
  participant Redis
  CLI->>Backend: POST telemetry (Error: truncateError(err))
  Backend->>Redis: HINCRBY msdl:telemetry:errors (if success=false and error valid)
  Backend->>Redis: load msdl:telemetry:errors
  Redis-->>Backend: aggregated error counts
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 feat/telemetry-error-field

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/starkSV/windows-iso-downloader/pull/21?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: failure by coderabbit.ai --> > [!CAUTION] > ## Review failed > > The pull request is closed. <!-- end of auto-generated comment: failure by coderabbit.ai --> <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro Plus **Run ID**: `d84088de-1517-4e12-9e08-acee21d66019` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 8258bd139d317f4fc70b1c166f5462f088002ad2 and 8ab322038b0d0f099b73ef65b0e3f706f34c430b. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `backend/main.go` * `cli/main.go` </details> </details> --- <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough This PR adds error tracking to the telemetry system. The CLI now truncates error messages to 150 characters and includes them in telemetry payloads. The backend accepts this new Error field, increments a Redis-based error counter on failed telemetry events, and includes error aggregates when loading telemetry data. ### Changes **Telemetry Error Tracking** |Layer / File(s)|Summary| |---|---| |**CLI error capture and truncation** <br> `cli/main.go`|Adds an `Error` field to `cliTelemetryPayload` and a `truncateError` helper that caps error text at 150 characters; wires `truncateError(err)` into the telemetry event sent via `sendTelemetry`.| |**Backend error ingestion and aggregation** <br> `backend/main.go`|Adds an `Error` field to `telemetryPayload`; in `handleTelemetry`, increments the `msdl:telemetry:errors` Redis hash when a failed event includes a valid (≤200 char) error; `loadTelemetryFromRedis` now also loads this hash into aggregated telemetry output.| **Estimated code review effort:** 1 (Trivial) | ~5 minutes ### Sequence Diagram(s) ```mermaid sequenceDiagram participant CLI participant Backend participant Redis CLI->>Backend: POST telemetry (Error: truncateError(err)) Backend->>Redis: HINCRBY msdl:telemetry:errors (if success=false and error valid) Backend->>Redis: load msdl:telemetry:errors Redis-->>Backend: aggregated error counts ``` </details> <!-- walkthrough_end --> <!-- finishing_touch_checkbox_start --> <details> <summary>✨ Finishing Touches</summary> <details> <summary>📝 Generate docstrings</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR - [ ] <!-- {"checkboxId": "3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch </details> <details> <summary>🧪 Generate unit tests (beta)</summary> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests - [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch `feat/telemetry-error-field` </details> </details> <!-- finishing_touch_checkbox_end --> <!-- This is an auto-generated comment: all tool run failures by coderabbit.ai --> > [!WARNING] > There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. > > <details> > <summary>🔧 golangci-lint (2.12.2)</summary> > > level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" > > > > > </details> <!-- end of auto-generated comment: all tool run failures by coderabbit.ai --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=starkSV/windows-iso-downloader&utm_content=21)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: shekhar/windows-iso-downloader#21
No description provided.