datadog package
Datadog APM tracing for @imqueue/rpc — distributed traces across IMQ service calls, with no changes to service or client code.
Import this package instead of dd-trace and call init() as usual. Every RPC then produces an imq.request span on the calling side and an imq.response span on the handling side, linked into one trace:
import tracer from '@imqueue/datadog';
tracer.init();
export default tracer;
Remarks
The default export IS the dd-trace tracer, and this package re-exports everything dd-trace does, so it is a drop-in replacement — every dd-trace API and option keeps working. What it adds is an imq integration registered with the tracer, plus the manual tools below.
Both halves of the integration can be configured like any other dd-trace plugin, together or separately:
tracer.use('imq', { client: false }); // trace incoming calls only
tracer.use('imq', { service: 'my-api' }); // report both halves as `my-api`
Ordering matters in one direction only. The hooks are installed at IMPORT time, before init(), because @imqueue/rpc reads its default options when a client or service is constructed — so any client or service built after the import is traced. init() is what enables the integration and starts reporting.
An ES module, as @imqueue/rpc is from v3 on: import it, do not require it. Needs @imqueue/rpc 3.x and dd-trace 6.x.
For manual spans inside application code there are trace() / traceEnd() and the traced() method decorator. Setting DISABLE_DD_SELF_TRACES=1 stops the agent tracing its own HTTP calls to Datadog while leaving other outbound requests traced.
Classes
|
Class |
Description |
|---|---|
|
Traces outgoing | |
|
The | |
|
Traces incoming |
Enumerations
|
Enumeration |
Description |
|---|---|
|
Which side of a call a span describes. Reported as Datadog's |
Functions
|
Function |
Description |
|---|---|
|
Adds The plugin manager reads that variable while enabling any plugin, and dd-trace throws a "Missing env/configuration in supported-configurations.json" error for every name it does not know — which would take the whole process down through an uncaught exception, since the lookup happens inside a diagnostics channel subscriber. | |
|
Enables the registered plugin. Separate from registration because the tracer's plugin manager ignores the announcement until it has a configuration, which | |
|
Installs the hooks into an Hooks the user configured themselves are preserved and invoked after the tracing ones, so enabling tracing never silently drops application behaviour. Calling this twice on the same object is a no-op. | |
|
Installs the tracing hooks into The hooks land on the default client and service options, so every client and service created afterwards is traced without touching application code. This deliberately does not use dd-trace's automatic module patching: that path needs the tracer loaded before | |
|
Announces a loaded module to the tracer's plugin manager, which is what makes it instantiate and configure the registered plugin. | |
|
Registers the Safe to call more than once, and safe to call before | |
|
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. | |
|
Builds a method decorator that wraps each call to the decorated method in its own span, finishing it when the method returns — or when the promise it returned settles. | |
|
Finishes the span trace() opened under this name and releases it, so the name can be reused. |
Interfaces
|
Interface |
Description |
|---|---|
|
The pair of hooks | |
|
Static shape of a | |
|
The subset of a diagnostics channel this package relies on. Channels are taken from dd-trace itself rather than from | |
|
Everything the plugins need to describe a call. Instances are created by the instrumentation in | |
|
Options accepted by | |
|
Options for the traced() method decorator. Every field is optional at the call site — | |
|
Datadog span tags as a flat string map. | |
|
Static shape of a | |
|
Structural type of dd-trace's |
Variables
|
Variable |
Description |
|---|---|
|
Property an in-flight call's context is kept under, on the request itself, so that | |
|
Key inside | |
|
Operation traced on the calling side of an imq RPC call. | |
|
Channels carrying client-side (outgoing call) events. | |
|
Hooks tracing outgoing calls, injecting the current context into the request. | |
|
Base class grouping several plugins under a single integration name. | |
|
Integration name. Together with the operation it forms the channel prefix dd-trace plugins subscribe to ( | |
|
Name of the diagnostics channel the tracer's plugin manager listens on to learn that an instrumented module has been loaded. | |
|
The tracer's plugin registry, keyed by the module name the load event is published for. Assigning into it is the only way for a package that does not live inside dd-trace to make its plugin discoverable. | |
|
Registry key the plugin is announced under. It is the name of the traced package, matching what dd-trace uses for its own integrations. | |
|
Operation traced on the handling side of an imq RPC call. | |
|
Channels carrying server-side (incoming call) events. | |
|
Hooks tracing incoming calls, reading the propagated context from the request. | |
|
Base class every tracing plugin derives from. |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.