Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubsub: Emit outstanding messages metrics for publishers #6180

Closed
schallert opened this issue Jun 15, 2022 · 2 comments · Fixed by #6187
Closed

pubsub: Emit outstanding messages metrics for publishers #6180

schallert opened this issue Jun 15, 2022 · 2 comments · Fixed by #6187
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@schallert
Copy link
Contributor

Is your feature request related to a problem? Please describe.

The PubSub package emits two metrics related to outstanding messages: OutstandingMessages and OutstandingBytes. The docs mention

OutstandingMessages is a measure of the number of outstanding messages held by the client before they are processed.

As a user, "messages held by the client" is something I care about in two contexts:

  1. In the context of publishing, I want to know how many messages the pubsub client has buffered that have not yet been published and persisted by the PubSub service.
  2. In the context of subscribing, I want to know how many messages the pubsub client has buffered that my application has not yet processed.

From the docs, I would have expected OutstandingMessages to emit metrics for both of those contexts. However, in practice, it seems like the client only increments OutstandingMessages in the context of (2) (code link). At first this was surprising, as it seems like the flow controller (which is used for both publishing and subscribing) is responsible for recording this metric. However, I saw that the metric is only registered with the subscription tag, which makes sense as to why it doesn't record for publishing to a topic.

This is frustrating, because I cannot tell from the pubsub client's internal metrics how many messages have been buffered but not yet persisted to PubSub. This is helpful for debugging cases where the PubSub service may be experiencing latency on Publish RPCs, I am experiencing network problems, etc.

Describe the solution you'd like

I would like the pubsub package to emit metrics on how many messages are outstanding in the context of publishing. I don't mind if this requires a separate View for producer outstanding metrics and subscriber outstanding metrics.

Describe alternatives you've considered

We have implemented our own metrics of how many messages have not yet been fully published by keeping track of PublishResults and decrementing counters when .Get() returns. It's not as clean as having this natively in the client.

@schallert schallert added the triage me I really want to be triaged. label Jun 15, 2022
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Jun 15, 2022
@hongalex
Copy link
Member

Hi, yeah as you surmised, outstanding messages/bytes only applies on the subscribe side. This is probably confusing because historically we did not have publisher-side flow control, so there was no concept of MaxOutstandingMessages/Bytes for the publisher side.

I'll consider this a feature request to add something like PublisherOutstandingMessages and PublisherOutstandingBytes to keep track of this.

@hongalex hongalex added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Jun 15, 2022
schallert added a commit to schallert/google-cloud-go that referenced this issue Jun 15, 2022
@schallert
Copy link
Contributor Author

I'll consider this a feature request to add something like PublisherOutstandingMessages and PublisherOutstandingBytes to keep track of this.

Gave this a shot.

schallert added a commit to schallert/google-cloud-go that referenced this issue Jun 16, 2022
hongalex added a commit that referenced this issue Jun 23, 2022
* feat(pubsub): report publisher outstanding metrics

Fixes #6180.

* fix topic tag

* flowcontroller: check all values on recordStat

* remove unknown value

Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants