OpenTelemetry SDK
    Preparing search index...

    Module @opentelemetry/instrumentation-grpc

    OpenTelemetry gRPC Instrumentation for Node.js

    NPM Published Version Apache License

    Note: This is an experimental package under active development. New releases may include breaking changes.

    This module provides automatic instrumentation for @grpc/grpc-js. Currently, version 1.x of @grpc/grpc-js is supported.

    npm install --save @opentelemetry/instrumentation-grpc
    

    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-js).

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

    const { trace } = require('@opentelemetry/api');
    const { ConsoleSpanExporter, TracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace');
    const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc');
    const { registerInstrumentations } = require('@opentelemetry/instrumentation');

    const tracerProvider = new TracerProvider({
    spanProcessors: [
    new SimpleSpanProcessor({ exporter: new ConsoleSpanExporter() })
    ]
    });
    trace.setGlobalTracerProvider(tracerProvider);
    // See https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/sdk-trace/
    // for a more complete example setting up a *context manager* and *propagators*.

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

    See examples/grpc-js for examples.

    gRPC instrumentation accepts the following configuration:

    Options Type Description
    ignoreGrpcMethods IgnoreMatcher[] 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.
    metadataToSpanAttributes object List of case insensitive metadata to convert to span attributes. Client and server (outgoing requests, incoming responses) metadata attributes will be converted to span attributes in the form of rpc.{request\response}.metadata.metadata_key, e.g. rpc.response.metadata.date

    The instrumentation-grpc versions v0.220.0 and later emit the stable v1.23.0+ semantic conventions.

    v1.23.0 semconv Short Description
    server.address Server domain name if available without reverse DNS lookup
    server.port Server port number
    Attribute Short Description
    rpc.method The name of the (logical) method being called, must be equal to the $method part in the span name.
    rpc.service The full (logical) name of the service being called, including its package name, if applicable.
    rpc.system A string identifying the remoting system.

    Apache 2.0 - See LICENSE for more information.

    GrpcInstrumentation
    GrpcInstrumentationConfig