0.13.0-alpha.1 • Published 3 years ago

@trendhim/opentelemetry-instrumentation-graphql v0.13.0-alpha.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
3 years ago

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);

graphQLInstrumentation.enable();

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

Useful links

License

Apache 2.0 - See LICENSE for more information.