Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions robot/web/request_counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"go.viam.com/rdk/utils/ssync"
)

// ReqLimitExceededURL is the URL for the troubleshooting steps for request limit exceeded errors.
const ReqLimitExceededURL = "https://docs.viam.com/dev/tools/common-errors/#req-limit-exceeded"

// RequestLimitExceededError is an error returned when a request is rejected
// because it would exceed the limit for concurrent requests to a given
// resource.
Expand All @@ -30,7 +33,8 @@ type RequestLimitExceededError struct {
}

func (e RequestLimitExceededError) Error() string {
return fmt.Sprintf("exceeded request limit %v on resource %v", e.limit, e.resource)
return fmt.Sprintf("exceeded request limit %v on resource %v, see %v for troubleshooting steps",
e.limit, e.resource, ReqLimitExceededURL)
}

// GRPCStatus allows this error to be converted to a [status.Status].
Expand Down Expand Up @@ -143,8 +147,8 @@ func (rc *RequestCounter) UnaryInterceptor(
apiMethod := extractViamAPI(info.FullMethod)
if resource := buildResourceLimitKey(req, apiMethod); resource != "" {
if ok := rc.incrInFlight(resource); !ok {
rc.logger.Warnw("Request limit exceeded for resource",
"method", apiMethod.full, "resource", resource)
rc.logger.Warnf("Request limit exceeded for method %s on resource %s. "+
"See %v for troubleshooting steps", apiMethod.full, resource, ReqLimitExceededURL)
return nil, &RequestLimitExceededError{
resource: resource,
limit: rc.inFlightLimit,
Expand Down
2 changes: 1 addition & 1 deletion robot/web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ func testResourceLimitsAndFTDC(
test.That(t, err, test.ShouldNotBeNil)
test.That(t, status.Convert(err).Code(), test.ShouldEqual, codes.ResourceExhausted)
test.That(t, err.Error(), test.ShouldEndWith,
fmt.Sprintf("exceeded request limit 1 on resource %v", keyPrefix))
fmt.Sprintf("exceeded request limit 1 on resource %v, see %v for troubleshooting steps", keyPrefix, web.ReqLimitExceededURL))

// In flight requests counter should still only be 1
stats = svc.RequestCounter().Stats().(map[string]int64)
Expand Down
Loading