Selectors
Select data from the router pipeline to extract
A selector is used to extract data from the Apollo Router's request lifecycle (pipeline) services and attach them to telemetry, specifically spans, instruments, conditions and events.
Each service of the router 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:
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.
Selector | Defaultable | Values | Description |
---|---|---|---|
trace_id | Yes | open_telemetry |datadog | The trace ID |
request_header | Yes | The name of the request header | |
response_header | Yes | The name of a response header | |
response_status | Yes | code |reason | The response status |
response_context | Yes | The name of a response context key | |
baggage | Yes | The name of a baggage item | |
env | Yes | The name of an environment variable | |
on_graphql_error | No | true | false |
static | No | A static string value |
Supergraph
The supergraph service is executed after query parsing but before query execution. It is GraphQL centric and deals with GraphQL queries and responses.
Selector | Defaultable | Values | Description |
---|---|---|---|
operation_name | Yes | string | hash |
operation_kind | No | string | The operation kind from the query |
query | Yes | string | The graphql query |
query_variable | Yes | The name of a graphql query variable | |
request_header | Yes | The name of a request header | |
response_header | Yes | The name of a response header | |
request_context | Yes | The name of a request context key | |
response_context | Yes | The name of a response context key | |
baggage | Yes | The name of a baggage item | |
env | Yes | The name of an environment variable | |
static | No | A static string value |
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.
Selector | Defaultable | Values | Description |
---|---|---|---|
subgraph_operation_name | Yes | string | hash |
subgraph_operation_kind | No | string | The operation kind from the subgraph query |
subgraph_query | Yes | string | The graphql query to the subgraph |
subgraph_query_variable | Yes | The name of a subgraph query variable | |
subgraph_response_data | Yes | Json Path into the subgraph response body data (it might impact performances) | |
subgraph_response_errors | Yes | Json Path into the subgraph response body errors (it might impact performances) | |
subgraph_request_header | Yes | The name of a subgraph request header | |
subgraph_response_header | Yes | The name of a subgraph response header | |
subgraph_response_status | Yes | code |reason | The status of a subgraph response |
supergraph_operation_name | Yes | string | hash |
supergraph_operation_kind | Yes | string | The operation kind from the supergraph query |
supergraph_query | Yes | string | The graphql query to the supergraph |
supergraph_query_variable | Yes | The name of a supergraph query variable | |
request_context | Yes | The name of a request context key | |
response_context | Yes | The name of a response context key | |
baggage | Yes | The name of a baggage item | |
env | Yes | The name of an environment variable | |
static | No | A static string value |