@trendhim/opentelemetry-instrumentation-graphql
TypeScript icon, indicating that this package has built-in type declarations

0.13.0-alpha.1 • Public • Published

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.

Package Sidebar

Install

npm i @trendhim/opentelemetry-instrumentation-graphql

Weekly Downloads

2

Version

0.13.0-alpha.1

License

Apache-2.0

Unpacked Size

68.6 kB

Total Files

24

Last publish

Collaborators

  • multiply