temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Frontend service_errors_resource_exhausted does not say which service refused the call

Open tsurdilo opened this issue 2 weeks ago • 1 comments

Currently the frontend metric:

service_errors_resource_exhausted{service_name="frontend"}

counts both

  • Calls that frontend refuses
  • Calls that history service refuses

Problem

When users see service_errors_resource_exhausted{service_name="frontend", resource_exhausted_cause="RpsLimit"}

its easy to conclude that frontend rate limit too low. Since however this counts also history refusals, if history refused most of these calls. Changing frontend rps limits does not help.

Currently only way to tell is to also look at

service_errors_resource_exhausted{service_name="history", resource_exhausted_cause="RpsLimit"}

rises at the same time. Currently the labels resource_exhausted_cause and _scope do not help as for cause its RpsLimit in both cases and the scope is Namespace in both cases.

Ask

Add label to service_errors_resource_exhausted that can tell users if service itself refused call or it came from a diff service that it itself called. For example add resource_exhausted_origin label where its values can be either "local" or "downstream" or the name of the called service that did the refusal

tsurdilo avatar Nov 19 '26 20:11 tsurdilo

Hi! I'd like to pick this up.

Proposed approach: add a resource_exhausted_origin tag to service_errors_resource_exhausted in recordErrorMetrics (common/rpc/interceptor/request_error_handler.go). The value is local when the error is one of the interceptor limiter sentinels (RateLimitServerBusy, ErrNamespaceRateLimitServerBusy, ErrNamespaceCountLimitServerBusy), the same set already used for the retry delay floor in service/frontend/fx.go, and downstream otherwise. Errors returned by history are reconstructed from the gRPC status, so they never match the sentinels.

Two questions before I open a PR:

  1. A few frontend handlers create their own ResourceExhausted errors: the batch operation concurrency limits and the Worker Deployment read rate limit. With a sentinel check they would be tagged downstream. Should I turn those into sentinels as well, so local covers every frontend-generated rejection?

  2. Are local / downstream acceptable values? Reporting the specific downstream service name would mean propagating it through the client error path, which seems out of scope for this change.

(EDIT : Not wasting time on the answer, I am opening a pr, the reviewer can iterate on this and it will be fixed accordingly)

mohakchakraborty2004 avatar Nov 19 '26 21:11 mohakchakraborty2004