Skip to content

Use GetPendingCount for the pending jobs gauge - #86

Open
shreyaabaranwal wants to merge 1 commit into
zerodha:masterfrom
shreyaabaranwal:pending-count-metric
Open

shreyaabaranwal wants to merge 1 commit into
zerodha:masterfrom
shreyaabaranwal:pending-count-metric

Conversation

@shreyaabaranwal

Copy link
Copy Markdown
Contributor

The dbtl_queue_pending_jobs gauge added in #84 calls Broker.GetPending() on
every scrape and uses len() of the result. On the Redis broker that is
LRANGE queue 0 -1, so each scrape pulls every pending job payload just to
count them.

tasqueue v2.3.0 (already the version in go.mod) has GetPendingCount() on the
Broker interface, which is an LLEN on Redis. GetPending() is also marked
deprecated in the interface. This switches the gauge to GetPendingCount().

The value is unchanged: LLEN and len(LRANGE 0 -1) return the same count,
and ETA-scheduled jobs are still excluded. The NATS broker returns an error for
both methods, so there's no behaviour change there either.

go build and go vet are clean. The client tests need a running server, so I've left them to CI.

@kalbhor

kalbhor commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

That's a nice spot! Makes sense

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