opentelemetry-js/experimental/packages/opentelemetry-instrumentati...
Marc Pichler bac68fc7d4
feat: add api release preparation scripts, github release creation scripts (#4704)
* feat: add more scripts for release creation

* Update scripts/extract-latest-release-notes.js

* fix: replace console.log() with console.warn(), ensure get-version.js is a version by checking against a regex

* chore: add comment to describe the regex
2024-05-21 14:36:43 +02:00
..
src feat(instrumentation): remove default value for config in base instrumentation constructor (#4695) 2024-05-17 10:19:57 +02:00
test refactor(instr-grpc): move to use SEMATTRS (#4633) 2024-04-16 11:31:15 +02:00
.eslintignore fix(instrumentation-grpc): instrument @grpc/grpc-js Client methods (#3804) 2023-08-01 16:12:40 +02:00
.eslintrc.js chore(deps): update dependency eslint to v8.43.0 (#3929) 2023-07-06 15:14:56 +02:00
.npmignore chore: split stable and experimental packages into groups using directories (#2462) 2021-09-10 17:14:55 -04:00
LICENSE chore: split stable and experimental packages into groups using directories (#2462) 2021-09-10 17:14:55 -04:00
README.md docs: align all supported versions to a common format (#4696) 2024-05-13 11:08:38 +02:00
package.json feat: add api release preparation scripts, github release creation scripts (#4704) 2024-05-21 14:36:43 +02:00
tsconfig.json chore: automatically generate tsconfigs (#3432) 2022-11-23 23:34:41 +08:00

README.md

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.

For automatic instrumentation see the @opentelemetry/sdk-trace-node package.

Installation

npm install --save @opentelemetry/instrumentation-grpc

Supported Versions

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-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('@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-js for examples.

gRPC Instrumentation Options

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

License

Apache 2.0 - See LICENSE for more information.