Episode 08tracesmetrics

Apollo Router already traces every subgraph call

Apollo Router reads one config file, and a telemetry block in it turns every GraphQL operation into a trace with the query plan and every subgraph fetch.

Ship telemetry toUse an OTLP endpoint you already have, from another vendor or your platform team. This one needs a one-time setup step: save your endpoint and the episodes fill it in.Set your endpointRun an OpenTelemetry Collector on your machine and watch telemetry arrive in its terminal. No account needed.More detailsShip straight to Bronto. You need an account and an API key with ingest permission.More details

Switch it on

Add a telemetry key to the router.yaml the router already loads. Every client operation then becomes one trace, with a span per query-plan node and per subgraph fetch.

telemetry:
  exporters:
    tracing:
      otlp:
        enabled: true
        protocol: http
        endpoint: https://ingestion.eu.bronto.io
        http:
          headers:
            x-bronto-api-key: ${env.BRONTO_API_KEY}
      common:
        service_name: storefront-router
    metrics:
      otlp:
        enabled: true
        protocol: http
        endpoint: https://ingestion.eu.bronto.io
        http:
          headers:
            x-bronto-api-key: ${env.BRONTO_API_KEY}
      common:
        service_name: storefront-router

The router fills ${env.BRONTO_API_KEY} from its own environment.

telemetry:
  exporters:
    tracing:
      otlp:
        enabled: true
        protocol: http
        endpoint: http://localhost:4318
      common:
        service_name: storefront-router
    metrics:
      otlp:
        enabled: true
        protocol: http
        endpoint: http://localhost:4318
      common:
        service_name: storefront-router

This assumes a Collector listening on localhost:4318; the Local Collector setup shows how to start one.

This uses the endpoint and auth header you saved in the setup guide.

telemetry:
  exporters:
    tracing:
      otlp:
        enabled: true
        protocol: http
        endpoint: YOUR_OTLP_ENDPOINT
        http:
          headers:
            YOUR_AUTH_HEADER: YOUR_AUTH_VALUE
      common:
        service_name: storefront-router
    metrics:
      otlp:
        enabled: true
        protocol: http
        endpoint: YOUR_OTLP_ENDPOINT
        http:
          headers:
            YOUR_AUTH_HEADER: YOUR_AUTH_VALUE
      common:
        service_name: storefront-router