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.

Each service of the pipeline (router, supergraph, subgraph) has its own available selectors.

An example of a selector, request_header, of the router 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.

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
studio_operation_idYestruefalse
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_errorNotruefalse
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 centric and deals with GraphQL queries and responses.

SelectorDefaultableValuesDescription
operation_nameYesstringhash
operation_kindNostringThe operation kind from the query
queryYesstringThe graphql query
query_variableYesThe name of a graphql query variable
request_headerYesThe name of a request header
response_headerYesThe name of a response header
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_errorNotruefalse
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_nameYesstringhash
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 performances)
subgraph_response_errorsYesJson Path into the subgraph response body errors (it might impact performances)
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
supergraph_operation_nameYesstringhash
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
Previous
Spans
Next
Standard Attributes
Rate articleRateEdit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company