Connect trace context with database commands

This guide describes how to extend database telemetry with trace context propagation using OpenTelemetry for Java.

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:

  • Supported only on Java 8 or higher.
  • Requires use of supported JDBC drivers.
  • Applies exclusively to applications using the Oracle or Microsoft SQL Server JDBC drivers (com.microsoft.sqlserver.jdbc.SQLServerDriver or oracle.jdbc.OracleDriver).

See Requirements for Java instrumentation for full compatibility details.

Environment Variable Configuration

To enable trace context propagation for MSSQL and Oracle in Splunk OpenTelemetry Java Agent, set the following environment variable:

Table 1. Environment Variable
NameDefault ValueDescription
OTEL_INSTRUMENTATION_SPLUNK_JDBC_ENABLEDfalseEnables experimental JDBC instrumentation for MSSQL and Oracle

To activate the feature, change the value to true.

Warning: This feature is experimental and not officially documented. Use with caution in production environments.

Enable Trace Context Propagation

To activate trace context propagation:

  1. Confirm that your application meets the compatibility requirements listed above.
  2. Set the environment variable OTEL_INSTRUMENTATION_SPLUNK_JDBC_ENABLED=true.
  3. Attach the Splunk OpenTelemetry Java Agent to your application.
  4. Use a supported JDBC driver:
    • com.microsoft.sqlserver.jdbc.SQLServerDriver (Microsoft SQL Server).
    • oracle.jdbc.OracleDriver (Oracle Database).

Once enabled, spans will be created for SQL commands and linked to the current trace context.

Note: This guide focuses on enabling trace context propagation. For guidance on analyzing database spans or correlating SQL activity with traces, refer to Splunk APM documentation.