0.2.4 • Published 2 years ago

supergraph-demo-opentelemetry v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

supergraph-demo-opentelemetry

Helper library for Open Telemetry instrumentation and distributed tracing in Apollo Federation using Apollo Gateway and Apollo Server.

See Apollo Federation Open Telemetry Docs for details on Open Telemetry support in Apollo Federation.

See apollographql/supergraph-demo for a working demo using this library:

opentelemetry

Basic Usage

See working example in the apollographql/supergraph-demo.

Apollo Gateway

Add this before you even import apollo-server, express, or http. Otherwise, your trace data will be incomplete.

new ApolloOpenTelemetry({
  type: 'router',
  name: 'router',
  exporter: {
    type: 'zipkin', // console, zipkin, collector, ...
    host: 'localhost', // default: localhost
    port: '9411', // default: exporter specific
  }
}).setupInstrumentation();

Apollo Gateway does trace context propagation so the subgraphs in a Apollo Federation can do distributed tracing.

Apollo Server

Add this before you even import apollo-server, express, or http. Otherwise, your trace data will be incomplete.

new ApolloOpenTelemetry({
  type: 'subgraph',
  name: 'inventory',
  exporter: {
    type: 'zipkin', // console, zipkin, collector, ...
    host: 'localhost', // default: localhost
    port: '9411', // default: exporter specific
  }
}).setupInstrumentation();

Learn More

Apollo Federation Open Telemetry Docs