-
Notifications
You must be signed in to change notification settings - Fork 249
feat: expose error types as a dimension and in expressions #2655
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| title: "Error Types" | ||
| description: "Router error type classifications for metrics and expressions" | ||
| icon: "triangle-exclamation" | ||
| --- | ||
|
|
||
| When an error occurs during request processing, the router classifies it into one of the following types. This classification is available via: | ||
| - **Expressions**: `request.errorType` and `subgraph.request.errorType` (see [Template Expressions](/router/configuration/template-expressions)) | ||
| - **Metrics**: the `wg.error.type` OTEL attribute (or `wg_error_type` in Prometheus) | ||
|
|
||
| | Value | Description | | ||
| |---|---| | ||
| | `rate_limit` | The request was rejected because the client exceeded the configured rate limit. | | ||
| | `unauthorized` | The request failed authentication or authorization. | | ||
| | `context_canceled` | The request was canceled, typically because the client disconnected before the response was sent. | | ||
| | `context_timeout` | The request timed out before a response could be produced. | | ||
| | `upgrade_failed` | A WebSocket upgrade request to a subgraph failed. | | ||
| | `edfs` | An error occurred in a Cosmo Streams (EDFS) data source. | | ||
| | `invalid_ws_subprotocol` | The client requested an unsupported WebSocket subprotocol. | | ||
| | `edfs_invalid_message` | A message received from a Cosmo Streams backend could not be parsed as valid JSON. | | ||
| | `merge_result` | The router failed to merge results from multiple subgraph responses. | | ||
| | `streams_handler_error` | An error occurred while handling a Cosmo Streams event. | | ||
| | `operation_blocked` | The operation was rejected by the operation blocker (e.g. blocked operation type or safelist violation). | | ||
| | `persisted_operation_not_found` | A persisted operation was requested but could not be found. | | ||
| | `validation_error` | The GraphQL operation failed parsing or validation against the schema. | | ||
| | `input_error` | The request body was malformed or otherwise invalid (e.g. invalid JSON, missing query). | | ||
| | `subgraph_error` | One or more subgraphs returned an error during execution. | | ||
| | `unknown` | An error occurred that does not match any known category. | | ||
| | `publish_error` | A Cosmo Streams publish operation failed (Kafka, NATS, or Redis). Only appears on stream produce/consume metrics. | | ||
| | `request_error` | A Cosmo Streams NATS request-reply operation failed. Only appears on stream produce/consume metrics. | |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -174,6 +174,7 @@ func (f *engineLoaderHooks) OnFinished(ctx context.Context, ds resolve.DataSourc | |||||||||||||||||||||
| exprCtx.Subgraph.Id = ds.ID | ||||||||||||||||||||||
| exprCtx.Subgraph.Name = ds.Name | ||||||||||||||||||||||
| exprCtx.Subgraph.Request.Error = WrapExprError(responseInfo.Err) | ||||||||||||||||||||||
| exprCtx.Subgraph.Request.ErrorType = getErrorType(responseInfo.Err).String() | ||||||||||||||||||||||
|
Comment on lines
176
to
+177
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't populate When Proposed fix exprCtx.Subgraph.Id = ds.ID
exprCtx.Subgraph.Name = ds.Name
exprCtx.Subgraph.Request.Error = WrapExprError(responseInfo.Err)
- exprCtx.Subgraph.Request.ErrorType = getErrorType(responseInfo.Err).String()
+ if responseInfo.Err != nil {
+ exprCtx.Subgraph.Request.ErrorType = getErrorType(responseInfo.Err).String()
+ } else {
+ exprCtx.Subgraph.Request.ErrorType = ""
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if value := ctx.Value(rcontext.FetchTimingKey); value != nil { | ||||||||||||||||||||||
| if fetchTiming, ok := value.(*atomic.Int64); ok { | ||||||||||||||||||||||
|
|
@@ -293,7 +294,11 @@ func (f *engineLoaderHooks) OnFinished(ctx context.Context, ds resolve.DataSourc | |||||||||||||||||||||
| metricSliceAttrs = append(metricSliceAttrs, attribute.StringSlice(v, errorCodesAttr)) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| f.metricStore.MeasureRequestError(ctx, metricSliceAttrs, metricAddOpt) | ||||||||||||||||||||||
| errType := getErrorType(responseInfo.Err) | ||||||||||||||||||||||
| errorTypeAttr := rotel.WgErrorType.String(errType.String()) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| metricAttrs = append(metricAttrs, errorTypeAttr) | ||||||||||||||||||||||
| f.metricStore.MeasureRequestError(ctx, metricSliceAttrs, otelmetric.WithAttributeSet(attribute.NewSet(metricAttrs...))) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| metricAttrs = append(metricAttrs, rotel.WgRequestError.Bool(true)) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert
subgraph_errorinstead ofunknownfor this deterministic subgraph-failure path.At Line 8466, Line 8541, Line 8862, Line 9046, Line 9121, and Line 9442, the test expects
wg.error.type="unknown"even though this scenario is an explicit subgraph fetch failure. That weakens coverage for the new error taxonomy and can hide regressions in subgraph classification.Suggested expectation fix
Also applies to: 8541-8541, 8862-8862, 9046-9046, 9121-9121, 9442-9442
🤖 Prompt for AI Agents