JSPM

  • Created
  • Published
  • Downloads 16474158
  • Score
    100M100P100Q262017F
  • License Apache-2.0

OpenTelemetry @opentelemetry/instrumentation-graphql automatic instrumentation package.

Package Exports

  • @opentelemetry/instrumentation-graphql

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@opentelemetry/instrumentation-graphql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenTelemetry Instrumentation GraphQL

Gitter chat NPM Published Version dependencies devDependencies Apache License

This module provides automated instrumentation and tracing for GraphQL in Node.js applications.

Installation

npm install @opentelemetry/instrumentation-graphql

Usage

'use strict';

const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');

const { ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');

const exporter = new CollectorTraceExporter({
  serviceName: 'basic-service',
});

const provider = new NodeTracerProvider({
  plugins: {
    http: { enabled: false, path: '@opentelemetry/plugin-http' },
    https: { enabled: false, path: '@opentelemetry/plugin-https' },
    express: { enabled: false, path: '@opentelemetry/plugin-express' },
  },
});

const graphQLInstrumentation = new GraphQLInstrumentation({
// optional params
  // allowAttributes: true,
  // depth: 2,
  // mergeItems: true,
});

graphQLInstrumentation.setTracerProvider(provider); // optional; uses global tracer by default

graphQLInstrumentation.enable();

provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

License

Apache 2.0 - See LICENSE for more information.