OpenTelemetry instrumentation for @connectrpc/connect-node
RPC client and server.
npm install @uphold/opentelemetry-connect-node
-
@connectrpc/connect-node
versions ^2.0.0
Enable the instrumentation offered by this package, like so:
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ConnectNodeInstrumentation } = require('@uphold/opentelemetry-connect-node');
const provider = new NodeTracerProvider({
spanProcessors: [new SimpleSpanProcessor(new ConsoleSpanExporter())]
});
provider.register();
registerInstrumentations({
instrumentations: [new ConnectNodeInstrumentation()]
});
The instrumentation accepts the following configuration:
Options | Type | Description |
---|---|---|
ignoreRequest |
IgnoreRequestMatcher |
The instrumentation will not trace any requests return true from the function. |
metadataToSpanAttributes |
MetadataToSpanAttributes |
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.{rpc_system}{request/response}.metadata.metadata_key , e.g. rpc.grpc.response.metadata.date
|
Non-unary requests will not be traced
Only unary requests will be traced. Server streaming, client streaming and bidirectional streaming are not supported due to a bug in context propagation for generator functions. Supposedly, there are workarounds but none of them worked. See https://github.com/open-telemetry/opentelemetry-js/issues/2951 and https://github.com/nodejs/node/issues/42237 for more details.
npm test
Licensed under MIT.