Skip to content

Commit

Permalink
Always report service error as additional metric with error-type tag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreiding committed Apr 19, 2022
1 parent 6deeed5 commit 762bf91
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ const (
ServiceRequests = iota
ServicePendingRequests
ServiceFailures
ServiceFailuresWithType
ServiceCriticalFailures
ServiceLatency
ServiceLatencyNoUserLatency
Expand Down Expand Up @@ -2253,6 +2254,7 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{
ServiceRequests: NewCounterDef("service_requests"),
ServicePendingRequests: NewGaugeDef("service_pending_requests"),
ServiceFailures: NewCounterDef("service_errors"),
ServiceFailuresWithType: NewCounterDef("service_errors_with_type"),
ServiceCriticalFailures: NewCounterDef("service_errors_critical"),
ServiceLatency: NewTimerDef("service_latency"),
ServiceLatencyNoUserLatency: NewTimerDef("service_latency_nouserlatency"),
Expand Down
2 changes: 2 additions & 0 deletions common/rpc/interceptor/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func (ti *TelemetryInterceptor) handleError(
err error,
) {

scope.Tagged(metrics.ServiceErrorTypeTag(err)).IncCounter(metrics.ServiceFailuresWithType)

if common.IsContextDeadlineExceededErr(err) {
scope.IncCounter(metrics.ServiceErrContextTimeoutCounter)
return
Expand Down
2 changes: 2 additions & 0 deletions service/frontend/adminHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,8 @@ func (adh *AdminHandler) startRequestProfile(scope int) (metrics.Scope, metrics.
}

func (adh *AdminHandler) error(err error, scope metrics.Scope) error {
scope.Tagged(metrics.ServiceErrorTypeTag(err)).IncCounter(metrics.ServiceFailuresWithType)

switch err := err.(type) {
case *serviceerror.Unavailable:
adh.logger.Error("unavailable error", tag.Error(err))
Expand Down
2 changes: 2 additions & 0 deletions service/frontend/operator_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ func (h *OperatorHandlerImpl) startRequestProfile(scope int) (metrics.Scope, met
}

func (h *OperatorHandlerImpl) error(err error, scope metrics.Scope, endpointName string) error {
scope.Tagged(metrics.ServiceErrorTypeTag(err)).IncCounter(metrics.ServiceFailuresWithType)

switch err := err.(type) {
case *serviceerror.Unavailable:
h.logger.Error("Unavailable error.", tag.Error(err), tag.Endpoint(endpointName))
Expand Down

0 comments on commit 762bf91

Please sign in to comment.