Skip to content

chore: add subscription activation and per-program metrics#929

Merged
thlorenz merged 3 commits intomasterfrom
thlorenz/grpc-metrics
Feb 9, 2026
Merged

chore: add subscription activation and per-program metrics#929
thlorenz merged 3 commits intomasterfrom
thlorenz/grpc-metrics

Conversation

@thlorenz
Copy link
Copy Markdown
Collaborator

@thlorenz thlorenz commented Feb 6, 2026

Summary

Add metrics for tracking gRPC subscription activations and per-program account updates to
better monitor subscription behavior and account update patterns.

Details

Added two new metrics to track subscription and account update activity:

Subscription Activation Tracking

  • account_subscription_activations_count: Tracks when new account subscriptions are activated, labeled by client_id

Per-Program Account Updates

  • per_program_account_updates_count: Tracks all account updates received grouped by program ID, labeled by both client_id and program
  • Updated program_subscription_account_updates_count description to clarify it only counts updates matching existing subscriptions

Summary by CodeRabbit

Release Notes

  • New Features
    • Subscription Activation Tracking: Metrics now capture account subscription activation events for improved visibility into subscription lifecycle.
    • Per-Program Account Updates: New metrics provide detailed insights into account updates by program, enabling better analysis of activity patterns and system behavior.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 6, 2026

Manual Deploy Available

You can trigger a manual deploy of this PR branch to testnet:

Deploy to Testnet 🚀

Alternative: Comment /deploy on this PR to trigger deployment directly.

⚠️ Note: Manual deploy requires authorization. Only authorized users can trigger deployments.

Comment updated automatically when the PR is synchronized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

The changes add new observability metrics to track account subscription activations and per-program account updates across the codebase. Two new metrics are introduced in the metrics module: ACCOUNT_SUBSCRIPTION_ACTIVATIONS_COUNT and PER_PROGRAM_ACCOUNT_UPDATES_COUNT, along with corresponding public API functions. These metrics are integrated into the chain laser actor and chain pubsub actor to increment counters when subscription activations occur and when program-sourced account updates are processed.

Suggested reviewers

  • GabrielePicco
  • bmuddha
  • lucacillario
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch thlorenz/grpc-metrics

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.

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@magicblock-metrics/src/metrics/mod.rs`:
- Around line 301-309: The metric PER_PROGRAM_ACCOUNT_UPDATES_COUNT currently
uses a free-form "program" label which can explode Prometheus cardinality;
change this by replacing the free-form label with a bounded alternative: either
remove the "program" label and aggregate by client only, introduce a
validated/allowlisted program label (accept only known program IDs) or map
program IDs to a fixed set of buckets/hashes (e.g., canonical names or safe
short buckets) before incrementing the IntCounterVec; implement the guard in the
code path that calls
PER_PROGRAM_ACCOUNT_UPDATES_COUNT.inc_with_label_values(...) so only
allowed/mapped values are used, or add a sanitization function (e.g.,
map_program_label) referenced where the metric is updated to enforce the bounded
set.

Comment thread magicblock-metrics/src/metrics/mod.rs
@thlorenz thlorenz requested a review from bmuddha February 9, 2026 11:14
Copy link
Copy Markdown
Collaborator

@bmuddha bmuddha left a comment

Choose a reason for hiding this comment

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

LGTM

@thlorenz thlorenz merged commit c02c036 into master Feb 9, 2026
19 checks passed
@thlorenz thlorenz deleted the thlorenz/grpc-metrics branch February 9, 2026 11:23
thlorenz added a commit that referenced this pull request Feb 9, 2026
* master:
  chore: add subscription activation and per-program metrics (#929)
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