Docs
Launch GraphOS Studio

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.

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

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 pipeline (router, supergraph, subgraph) has its own available selectors.

Router

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

SelectorDefaultableValuesDescription
trace_idYesopen_telemetry|datadogThe trace 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

Supergraph

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

SelectorDefaultableValuesDescription
operation_nameYesThe operation name from the query
operation_kindNoquery|mutation|subscriptionThe operation kind from the query
queryYesquery|hashThe graphql query
query_variableYesThe name of a graphql query variable
response_bodyYesJson Path into the response body
request_headerYesThe name of a request header
response_headerYesThe name of a response header
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

Subgraph

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

SelectorDefaultableValuesDescription
subgraph_operation_nameYesThe operation name from the subgraph query
subgraph_operation_kindNoquery|mutation|subscriptionThe operation kind from the subgraph query
subgraph_queryYesThe 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_statusYesThe name of a subgraph response header
supergraph_operation_nameYesThe operation name from the supergraph query
supergraph_operation_kindYesquery|mutation|subscriptionThe operation kind from the supergraph query
supergraph_queryYesThe 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
Previous
Spans
Next
Standard attributes
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company