@uphold/opentelemetry-instrumentation-connect-node
v1.0.0
Published
OpenTelemetry instrumentation for `@connectrpc/connect-node` RPC client and server
Readme
@uphold/opentelemetry-instrumentation-connect-node
OpenTelemetry instrumentation for @connectrpc/connect-node RPC client and server.
Installation
npm install @uphold/opentelemetry-instrumentation-connect-nodeSupported versions
@connectrpc/connect-nodeversions^2.0.0
Usage
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-instrumentation-connect-node');
const provider = new NodeTracerProvider({
spanProcessors: [new SimpleSpanProcessor(new ConsoleSpanExporter())]
});
provider.register();
registerInstrumentations({
instrumentations: [new ConnectNodeInstrumentation()]
});Instrumentation options
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 |
Caveats
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.
Tests
npm testLicense
Licensed under MIT.
