Connect trace context with database commands
This guide describes how to extend database telemetry with trace context propagation using OpenTelemetry for Node.js.
Check compatibility and requirements
Before enabling trace context propagation, review the required runtime, configuration, and database conditions. These prerequisites ensure that OpenTelemetry features can operate correctly and safely in your environment.
Runtime compatibility
Trace context propagation is supported only under specific runtime conditions:
- Requires Node.js version 18 or higher.
- Applies exclusively to applications using Microsoft SQL Server with the
tediousdriver. - The only supported instrumentation is for
tedious. No other database instrumentations are available at this time.
Configuration option
To enable trace context propagation for Microsoft SQL Server in OpenTelemetry for Node.js, set the following configuration option:
| Configuration option | Default value | Description |
|---|---|---|
enableTraceContextPropagation
| false | Enables trace context propagation using SET CONTEXT_INFO for the current connection. |
SET CONTEXT_INFO command to set trace context information for the current connection, which results in an additional round-trip to the database.
Enable trace context propagation
To activate trace context propagation:
- Confirm that your application meets the compatibility requirements listed above.
- Use the
tediousdriver to connect to Microsoft SQL Server. - Configure the OpenTelemetry instrumentation with
enableTraceContextPropagation: true - Execute database commands within an active trace context.