Selectors

Select data from the router pipeline to extract


A selector is used to extract data from the GraphOS Router's request lifecycle (pipeline) services and attach them to telemetry, specifically spans, instruments, conditions and events.

An example of a selector, request_header, of the router service on a custom span attribute:

YAML
router.yaml
1telemetry:
2  instrumentation:
3    spans:
4      router:
5        attributes:
6          "my_attribute":
7            # ...
8            request_header: "x-my-header"

Selector configuration reference

Each service of the router pipeline (router, supergraph, subgraph) has its own available selectors. You can also extract GraphQL metrics from the response data the router returns to clients.

Router

The router service is the initial entrypoint for all requests. It is HTTP centric and deals with opaque bytes.

SelectorDefaultableValuesDescription
trace_idYesopen_telemetry|datadogThe trace ID
operation_nameYesstring|hashThe operation name from the query
studio_operation_idYestrue|falseThe Apollo Studio operation id
request_headerYesThe name of the request header
request_contextYesThe name of a request context key
response_headerYesThe name of a response header
response_statusYescode|reasonThe response status
response_contextYesThe name of a response context key
baggageYesThe name of a baggage item
envYesThe name of an environment variable
on_graphql_errorNotrue|falseBoolean set to true if the response payload contains a GraphQL error
staticNoA static string value
errorNoreasona string value containing error reason when it's a critical error

Supergraph

The supergraph service is executed after query parsing but before query execution. It is GraphQL centric and deals with GraphQL queries and responses.

SelectorDefaultableValuesDescription
operation_nameYesstring|hashThe operation name from the query
operation_kindNostringThe operation kind from the query
queryYesstring|aliases|depth|height|root_fieldsThe GraphQL query
query_variableYesThe name of a GraphQL query variable
request_headerYesThe name of a request header
response_headerYesThe name of a response header
is_primary_responseNotrue|falseBoolean returning true if it's the primary response and not events like subscription events or deferred responses
response_dataYesJSON Path into the supergraph response body data (it might impact performance)
response_errorsYesJSON Path into the supergraph response body errors (it might impact performance)
request_contextYesThe name of a request context key
response_contextYesThe name of a response context key
on_graphql_errorNotrue|falseBoolean set to true if the response payload contains a GraphQL error
baggageYesThe name of a baggage item
envYesThe name of an environment variable
staticNoA static string value
errorNoreasonA string value containing error reason when it's a critical error

Subgraph

The subgraph service executes multiple times during query execution, with each execution representing a call to a single subgraph. It is GraphQL centric and deals with GraphQL queries and responses.

SelectorDefaultableValuesDescription
subgraph_operation_nameYesstring|hashThe operation name from the subgraph query
subgraph_operation_kindNostringThe operation kind from the subgraph query
subgraph_queryYesstringThe GraphQL query to the subgraph
subgraph_nameNotrue|falseThe subgraph name
subgraph_query_variableYesThe name of a subgraph query variable
subgraph_response_dataYesJSON Path into the subgraph response body data (it might impact performance)
subgraph_response_errorsYesJSON Path into the subgraph response body errors (it might impact performance)
subgraph_request_headerYesThe name of a subgraph request header
subgraph_response_headerYesThe name of a subgraph response header
subgraph_response_statusYescode|reasonThe status of a subgraph response
subgraph_on_graphql_errorNotrue|falseBoolean set to true if the subgraph response payload contains a GraphQL error
supergraph_operation_nameYesstring|hashThe operation name from the supergraph query
supergraph_operation_kindYesstringThe operation kind from the supergraph query
supergraph_queryYesstringThe graphql query to the supergraph
supergraph_query_variableYesThe name of a supergraph query variable
supergraph_request_headerYesThe name of a supergraph request header
subgraph_resend_countYestrue|falseNumber of retries for an http request to a subgraph
request_contextYesThe name of a request context key
response_contextYesThe name of a response context key
baggageYesThe name of a baggage item
envYesThe name of an environment variable
staticNoA static string value
errorNoreasonA string value containing error reason when it's a critical error
cacheNohit|missReturns the number of cache hit or miss for this subgraph request

GraphQL

GraphQL metrics are extracted from the response data the router returns to client requests.

SelectorDefaultableValuesDescription
list_lengthNovalueThe length of a list from the response data
field_nameNostringThe name of a field from the response data
field_typeNostringThe type of a field from the response data
type_nameNoThe GraphQL type from the response data
operation_nameYesstring|hashThe operation name of the query
staticNoA static string value
Feedback

Edit on GitHub

Forums