0.26.0 • Published 3 years ago

@sprkl/opentelemetry-instrumentation-grpc v0.26.0

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

Sprkl OpenTelemetry gRPC Instrumentation for Node.js

This repository fixes NestJS and gRPC instrumentation collision issue described here: https://github.com/open-telemetry/opentelemetry-js/issues/2580

Installation

npm install --save @sprkl/opentelemetry-instrumentation-grpc

Usage

OpenTelemetry gRPC Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with gRPC or (grpc-js).

To load a specific instrumentation (gRPC in this case), specify it in the Node Tracer's configuration.

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { GrpcInstrumentation } = require('@sprkl/opentelemetry-instrumentation-grpc');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();

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

registerInstrumentations({
  instrumentations: [new GrpcInstrumentation()]
});

See examples/grpc or examples/grpc-js for examples.

gRPC Instrumentation Options

gRPC instrumentation accepts the following configuration:

OptionsTypeDescription
ignoreGrpcMethodsIgnoreMatcher[]gRPC instrumentation will not trace any methods that match anything in this list. You may pass a string (case-insensitive match), a RegExp object, or a filter function.

Useful links

License

Apache 2.0 - See LICENSE for more information.