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
This module provides automated instrumentation and tracing for GraphQL in Node.js applications.
Installation
npm install @opentelemetry/instrumentation-graphqlUsage
'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();
Useful links
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us on gitter
License
Apache 2.0 - See LICENSE for more information.