Skip to content

Add new HookMetricEmit that can emit arbitrary metrics#1285

Open
brandur wants to merge 1 commit into
masterfrom
brandur-metrics-hook
Open

Add new HookMetricEmit that can emit arbitrary metrics#1285
brandur wants to merge 1 commit into
masterfrom
brandur-metrics-hook

Conversation

@brandur

@brandur brandur commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

I was thinking about observability in River the other day, and how if
one were trying to track River performance degradation due to dead
tuples, how you might do so. Surprisingly, I don't think it's really
possible under our current framework -- the best proxy for it is time to
lock jobs, a metric which we don't provide any way of extracting out of
River.

Here, add a new hook called HookMetricEmit. The idea behind it is that it
may receive an arbitrary metric that River starts to emit, and handle it
by passing it onto a metrics system of choice, like OTEL, DataDog, or
whatever.

Within HookMetricEmit, add two specific metrics to get us started:

  • JobGetAvailableDurationMetric: Time to lock available jobs. This
    will start to show significant degradation in case of dead tuples.

  • JobGetAvailableCountMetric: Number of jobs locked while getting
    available. This is somewhat useful in seeing how well batch locking is
    working out in a program (i.e. are we locking one job at a time or
    100?).

@brandur brandur changed the title Add new HookMetric that can emit arbitrary metrics Add new HookMetricEmit that can emit arbitrary metrics Jun 12, 2026
brandur added a commit to riverqueue/rivercontrib that referenced this pull request Jun 12, 2026
Here, build on the proposal in [1] to add a metric hook to River, and
start emitting metrics for the time to lock jobs and the number of jobs
locked. Especially the first metric is generally very useful for looking
for queue degradation due to dead tuples.

[1] riverqueue/river#1285
@brandur brandur force-pushed the brandur-metrics-hook branch from c9d83e3 to c3c56ed Compare June 12, 2026 13:56
I was thinking about observability in River the other day, and how if
one were trying to track River performance degradation due to dead
tuples, how you might do so. Surprisingly, I don't think it's really
possible under our current framework -- the best proxy for it is time to
lock jobs, a metric which we don't provide any way of extracting out of
River.

Here, add a new hook called `HookMetricEmit`. The idea behind it is that it
may receive an arbitrary metric that River starts to emit, and handle it
by passing it onto a metrics system of choice, like OTEL, DataDog, or
whatever.

Within `HookMetricEmit`, add two specific metrics to get us started:

* `JobGetAvailableDurationMetric`: Time to lock available jobs. This
  will start to show significant degradation in case of dead tuples.

* `JobGetAvailableCountMetric`: Number of jobs locked while getting
  available. This is somewhat useful in seeing how well batch locking is
  working out in a program (i.e. are we locking one job at a time or
  100?).
@brandur brandur force-pushed the brandur-metrics-hook branch from c3c56ed to e54c7ad Compare June 12, 2026 15: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