Join us from October 8-10 in New York City to learn the latest tips, trends, and news about GraphQL Federation and API platform engineering.Join us for GraphQL Summit 2024 in NYC
Docs
Start for Free

Selectors

Select data from the router pipeline to extract


A selector is used to extract data from the '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 service on a custom span attribute:

router.yaml
telemetry:
instrumentation:
spans:
router:
attributes:
"my_attribute":
# ...
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 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
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 service is executed after 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 performances)
response_errorsYesJson Path into the supergraph response body errors (it might impact performances)
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 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_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
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

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
Previous
Spans
Next
Standard Attributes
Rate articleRateEdit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc., d/b/a Apollo GraphQL.

Privacy Policy

Company