Skip to content

fix(ups): add metrics#4368

Open
MasterPtato wants to merge 1 commit intofix-ups-formalize-subjectsfrom
fix-ups-add-metrics
Open

fix(ups): add metrics#4368
MasterPtato wants to merge 1 commit intofix-ups-formalize-subjectsfrom
fix-ups-add-metrics

Conversation

@MasterPtato
Copy link
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MasterPtato
Copy link
Contributor Author

MasterPtato commented Mar 6, 2026

@railway-app
Copy link

railway-app bot commented Mar 6, 2026

🚅 Deployed to the rivet-pr-4368 environment in rivet-frontend

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web Mar 6, 2026 at 2:29 am
frontend-cloud 😴 Sleeping (View Logs) Web Mar 6, 2026 at 2:24 am
frontend-inspector 😴 Sleeping (View Logs) Web Mar 6, 2026 at 2:24 am
mcp-hub ✅ Success (View Logs) Web Mar 6, 2026 at 2:18 am
ladle ❌ Build Failed (View Logs) Web Mar 6, 2026 at 2:17 am

@claude
Copy link

claude bot commented Mar 6, 2026

PR Review: fix(ups): add metrics

This PR adds new counters/gauges/histograms to the universalpubsub layer and renames existing metrics from plural to singular form (e.g. ups_local_subscribers_count to ups_local_subscriber_count). Overall a solid observability improvement with a few things worth addressing.


Breaking Change: Metric Renames

The existing gauge names are changing:

  • ups_local_subscribers_count to ups_local_subscriber_count
  • ups_reply_subscribers_count to ups_reply_subscriber_count
  • ups_memory_subscribers_count to ups_memory_subscriber_count
  • ups_postgres_subscriptions_count to ups_postgres_subscription_count

Any existing dashboards, Prometheus recording rules, or alerts referencing the old names will silently break. Worth noting in the PR description if these are in active use.


Code Quality

Repeated inline if-let pattern (3 occurrences in pubsub.rs)

The same expression appears three times inside next() and Drop::drop(). A small helper would clean this up:

fn root_subject_str(&self) -> &str {
    self.root_subject.as_deref().unwrap_or("unknown")
}

This pattern is already handled cleanly in Subscriber::new() via the subject_str local, just not reused downstream.

Shadowed variable in publish_inner

let subject_str = T::root();
let subject_str = subject_str.as_deref().unwrap_or("unknown");

These two lines can be collapsed to: let subject_str = T::root().as_deref().unwrap_or("unknown");

TODO comment is a question, not an action item (memory/mod.rs)

// TODO: Why not use drop impl?

Per project conventions, comments should be complete sentences. Either answer the question and remove the comment, or convert it to an explanatory note describing why the GC task approach is needed. If follow-up is needed, open a separate issue rather than leaving it inline.

Blank lines removed between metric sections in metrics.rs

The blank lines between the Memory driver and Postgres driver comment blocks were removed. Restoring them would match the original grouping style.


Potential Issue: High-Cardinality Label Documentation

SUBSCRIBER_COUNT, ACTIVE_SUBSCRIBER_COUNT, MESSAGE_RECV_COUNT, MESSAGE_SEND_COUNT, and BYTES_PER_MESSAGE all use a subject/root_subject label. The Subject::root() default returns None, so any caller passing a raw &str or &String falls through to "unknown". A doc comment on Subject::root() explaining that implementors should override it to get meaningful per-subject metrics would help future implementors avoid having all traffic bucketed under "unknown".


Minor Nit

The histogram bucket list in BYTES_PER_MESSAGE is quite long on one line. Breaking it across lines would improve readability.


Summary

Area Status
Breaking metric renames Needs coordination with any existing dashboards
Repeated inline pattern Minor refactor recommended
TODO question comment Should be resolved or removed
High-cardinality label docs Worth a doc comment on Subject::root()
Logic / correctness Looks correct
New metrics coverage Good: counts, gauges, and histograms all present

The new metric additions are well-chosen and the root() approach to controlling cardinality is the right design. Addressing the repeated pattern and the TODO comment would tighten things up before merging.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 6, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4368

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4368

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4368

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4368

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4368

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4368

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4368

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4368

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4368

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4368

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4368

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4368

commit: ba4b5d9

@MasterPtato MasterPtato force-pushed the fix-ups-add-metrics branch from 6ab4653 to 1ff340f Compare March 6, 2026 02:39
@MasterPtato MasterPtato force-pushed the fix-ups-add-metrics branch from 1ff340f to 4d4e7d1 Compare March 6, 2026 21:09
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.

1 participant