opentelemetry package
OpenTelemetry instrumentation for @imqueue/rpc — distributed traces across IMQ service calls, with no changes to service or client code.
Register ImqueueInstrumentation once at start-up and every RPC made through @imqueue/rpc produces a CLIENT span on the calling side and a SERVER span on the handling side, linked into one trace. For anything the automatic spans do not cover there are two manual tools: the traced() method decorator, and the traceStart()/traceEnd() pair for an arbitrary block of code.
Remarks
Trace context travels in the IMQ request metadata, so a call chain stays a single trace across processes and queues. The instrumentation works by mutating @imqueue/rpc's exported default option singletons rather than by hooking module loading — see ImqueueInstrumentation for why that matters and what it implies.
This package only *produces* spans. Exporting them is the host application's job: register a tracer provider from the OpenTelemetry SDK, or the spans go nowhere.
Example
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { ImqueueInstrumentation } from '@imqueue/opentelemetry';
new NodeTracerProvider().register();
registerInstrumentations({
instrumentations: [new ImqueueInstrumentation()],
});
Classes
|
Class |
Description |
|---|---|
|
OpenTelemetry instrumentation for
Two consequences of patching singletons rather than intercepting imports. Clients and services constructed BEFORE |
Enumerations
|
Enumeration |
Description |
|---|---|
|
Attribute keys this package sets on every span it creates. | |
|
The span names this package emits. There are only three, and they identify the KIND of operation, not which method ran — the specific method is carried by the | |
|
Which side of a call a span describes. Written to the |
Functions
|
Function |
Description |
|---|---|
|
Builds a method decorator that wraps each call to the decorated method in its own span, ending it when the method returns — or when the promise it returned settles. | |
|
Ends the span traceStart() opened under this name and releases it, so the name can be reused. | |
|
Starts a named span for tracing a block of code that no decorator can wrap, to be closed later by traceEnd() with the same name. |
Interfaces
|
Interface |
Description |
|---|---|
|
The subset of | |
|
The | |
|
Span attributes as a flat string map. | |
|
Options for the |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.