OpenTelemetry standard attributes

Attach standard attributes to router telemetry


OpenTelemetry semantic conventions define a set of standard attributes that can be attached to spans, instruments and events. These attributes are used to filter and group data in your application performance monitor (APM).

The attributes available depend on the service of the router pipeline.

For example, set the standard attribute http.response.status_code on the router span:

YAML
router.yaml
1telemetry:
2  instrumentation:
3    spans:
4      router:
5        attributes:
6          # Standard attributes
7          http.response.status_code: true

Alias

If you don't want to use the standard name you can still create an alias and use that alias for the name, for example:

YAML
router.yaml
1telemetry:
2  instrumentation:
3    spans:
4      router:
5        attributes:
6          # Standard attributes
7          http.response.status_code:
8            alias: status_code # It will be named status_code instead of http.response.status_code

Attribute configuration reference

A router's request lifecycle has three major services:

  • Router service - Handles an incoming request before it is parsed. Works within a context of opaque bytes.

  • Supergraph service - Handles a request after it has been parsed and before it is sent to the subgraph. Works within a GraphQL context.

  • Subgraph service - Handles a request after it has been sent to the subgraph. Works within a GraphQL context.

Each service supports a unique set of standard attributes.

Router

Standard attributes of the router service:

AttributeValuesDescription
error.typeDescribes a class of error the operation ended with
http.request.body.sizeThe size of the request payload body in bytes
http.request.methodHTTP request method
http.response.body.sizeThe size of the response payload body in bytes
http.response.status_codeHTTP response status code
network.protocol.nameOSI application layer or non-OSI equivalent
network.protocol.versionVersion of the protocol specified in network.protocol.name
network.transportOSI transport layer
network.typeOSI network layer or non-OSI equivalent
user_agent.originalValue of the HTTP User-Agent header sent by the client
http.routeThe matched route (path template in the format used by the respective server framework)
network.local.addressLocal socket address. Useful in case of a multi-IP host
network.local.portLocal socket port. Useful in case of a multi-port host
network.peer.addressPeer address of the network connection - IP address or Unix domain socket name
network.peer.portPeer port number of the network connection
server.addressName of the local HTTP server that received the request
server.portPort of the local HTTP server that received the request
url.pathThe URI path component
url.queryThe URI query component
url.schemeThe scheme portion of the URL, such as "https" or "http"
 note
The http.request.header.<key> and http.response.header.<key> attributes are not available as standard attributes, but they can be configured using a custom attribute.For example, to configure an attribute for x-my-header on router spans:
YAML
router.yaml
1telemetry:
2  instrumentation:
3    spans:
4      router:
5        attributes:
6          "http.request.header.x-my-header":
7            request_header: "x-my-header"

Supergraph

Standard attributes of the supergraph service:

AttributeValuesDescription
graphql.operation.nameThe operation name from the graphql query (need spec_compliant mode to disable it)
graphql.operation.typequery|mutation|subscriptionThe operation kind from the subgraph query
graphql.documentThe GraphQL query to the subgraph (need spec_compliant mode to disable it)

Subgraph

Standard attributes of the subgraph service:

AttributeValuesDescription
subgraph.nameThe name of the subgraph (need spec_compliant mode to disable it)
subgraph.graphql.operation.nameThe operation name from the subgraph query (need spec_compliant mode to disable it)
subgraph.graphql.operation.typequery|mutation|subscriptionThe operation kind from the subgraph query
subgraph.graphql.documentThe GraphQL query to the subgraph (need spec_compliant mode to disable it)
Feedback

Edit on GitHub

Forums