feat(backend): approximate distinct-source count for Sentinel rejections #29

Merged
starkSV merged 2 commits from feat/sentinel-distinct-sources into main 2026-07-13 12:46:06 +05:30
starkSV commented 2026-07-13 12:45:42 +05:30 (Migrated from github.com)

Summary

  • Adds an all-time Sentinel-rejection counter and an approximate distinct-source count (Redis HyperLogLog seeded from the reporting IP, no raw IPs stored)
  • /metrics now exposes flat sentinel_errors and sentinel_distinct_sources_est fields

Why

  • CLI telemetry showed a growing count of Sentinel rejections with no way to tell whether they come from one user retrying repeatedly or many distinct users independently getting blocked

Test plan

  • Backend builds clean, go vet passes
  • Verified PFAdd/PFCount compile against the redis client (build succeeds)
  • After merge: redeploy backend, check /metrics for the new fields once a Sentinel error occurs

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when generating Microsoft download links by ensuring session cookies are available for requests.
  • New Features

    • Added Sentinel error tracking and distinct-source estimates to telemetry.
    • Exposed Sentinel error statistics through the metrics endpoint.
## Summary - Adds an all-time Sentinel-rejection counter and an approximate distinct-source count (Redis HyperLogLog seeded from the reporting IP, no raw IPs stored) - /metrics now exposes flat sentinel_errors and sentinel_distinct_sources_est fields ## Why - CLI telemetry showed a growing count of Sentinel rejections with no way to tell whether they come from one user retrying repeatedly or many distinct users independently getting blocked ## Test plan - Backend builds clean, go vet passes - Verified PFAdd/PFCount compile against the redis client (build succeeds) - After merge: redeploy backend, check /metrics for the new fields once a Sentinel error occurs <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved reliability when generating Microsoft download links by ensuring session cookies are available for requests. * **New Features** * Added Sentinel error tracking and distinct-source estimates to telemetry. * Exposed Sentinel error statistics through the metrics endpoint. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2026-07-13 12:46:01 +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: eb903836-26e2-4bfc-a49b-1f65ff460848

📥 Commits

Reviewing files that changed from the base of the PR and between 6e374e6a45 and 327c5e195d.

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

📝 Walkthrough

Walkthrough

The pull request initializes missing session cookie jars for Microsoft download-link requests and adds Redis-backed Sentinel failure counts and distinct-source estimates to telemetry and metrics responses.

Changes

Download request cookie handling

Layer / File(s) Summary
Initialize the download request cookie jar
backend/main.go
The Microsoft download-link request now creates a simpleCookieJar when the session jar is missing or legacy.

Sentinel telemetry aggregation

Layer / File(s) Summary
Record and expose Sentinel statistics
backend/main.go
Failed telemetry containing “Sentinel” updates a Redis counter and HyperLogLog, and /metrics returns the resulting error count and distinct-source estimate.

Estimated code review effort: 2 (Simple) | ~10 minutes

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/sentinel-distinct-sources

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/29?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**: `eb903836-26e2-4bfc-a49b-1f65ff460848` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 6e374e6a45209a4db2a8a90764685edc604bcbbf and 327c5e195dfc9d77ee89e1fee0ad5b8812e92588. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `backend/main.go` </details> </details> --- <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The pull request initializes missing session cookie jars for Microsoft download-link requests and adds Redis-backed Sentinel failure counts and distinct-source estimates to telemetry and metrics responses. ### Changes **Download request cookie handling** |Layer / File(s)|Summary| |---|---| |**Initialize the download request cookie jar** <br> `backend/main.go`|The Microsoft download-link request now creates a `simpleCookieJar` when the session jar is missing or legacy.| **Sentinel telemetry aggregation** |Layer / File(s)|Summary| |---|---| |**Record and expose Sentinel statistics** <br> `backend/main.go`|Failed telemetry containing “Sentinel” updates a Redis counter and HyperLogLog, and `/metrics` returns the resulting error count and distinct-source estimate.| **Estimated code review effort:** 2 (Simple) | ~10 minutes </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/sentinel-distinct-sources` </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=29)! 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#29
No description provided.