Skip to content

MQ-1154 Add metrics() method to Queue binding#6246

Open
KennethRuan wants to merge 1 commit intocloudflare:mainfrom
KennethRuan:kruan/MQ-952-queue-metrics-api
Open

MQ-1154 Add metrics() method to Queue binding#6246
KennethRuan wants to merge 1 commit intocloudflare:mainfrom
KennethRuan:kruan/MQ-952-queue-metrics-api

Conversation

@KennethRuan
Copy link

@KennethRuan KennethRuan commented Mar 4, 2026

Summary

Adds a new metrics() method to the WorkerQueue binding. The method returns consumer backlog information via a GET subrequest to the /metrics endpoint on the upstream Queues service.

Changes

This PR introduces changes to queue.c++ and queue.h to implement the metrics() method. The new method definition is gated behind the queues_metrics_api compat flag and returns the following response type:

type QueueMetrics = {
  backlogCount: number;
  backlogBytes: number;
  oldestMessageTimestamp: number;
};

The upstream changes can be found here:
https://gitlab.cfdata.org/cloudflare/mq/queue-broker-worker/-/merge_requests/1734
https://gitlab.cfdata.org/cloudflare/mq/queue-broker-worker/-/merge_requests/1759

Testing

  • bazel test //src/workerd/api/tests:queue-test@ - queue send/sendBatch tests + error-codes tests pass
  • bazel test //src/workerd/api/tests:queue-test@all-compat-flags
  • bazel test //src/workerd/api/tests:queue-metrics-test@ - tests new api with flag enabled + flag disabled
  • bazel test //src/workerd/api/tests:queue-metrics-test@all-compat-flags

@KennethRuan KennethRuan requested review from a team as code owners March 4, 2026 23:17
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@KennethRuan
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Mar 5, 2026
@KennethRuan KennethRuan force-pushed the kruan/MQ-952-queue-metrics-api branch from 7f7bc65 to 640cb4c Compare March 5, 2026 17:43
@KennethRuan KennethRuan requested a review from sdnts March 5, 2026 17:52
@KennethRuan KennethRuan force-pushed the kruan/MQ-952-queue-metrics-api branch 4 times, most recently from a0e4962 to ce9f7b5 Compare March 18, 2026 02:59
@KennethRuan KennethRuan force-pushed the kruan/MQ-952-queue-metrics-api branch from 9824741 to 1c84049 Compare March 22, 2026 20:07
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.

3 participants