Correlate database queries with Splunk APM traces

Correlate database queries with Splunk APM traces.

Benefits

Correlating database queries with Splunk APM traces provides end-to-end visibility to:

  • Pinpoint latency: Determine whether delays occur in the application, the network, or the database.
  • Reduce MTTR: Eliminate manual matching by navigating directly from queries to related spans.
  • Optimize performance: Prioritize remediation based on the full query path across services and database internals.

How it works

Propagated span or trace information is available only for query samples.

Database receivers in collect query samples every 10 seconds by default. Only those APM traces that correspond to the queries captured as samples will have correlation data recorded. Other traces won't have this correlation present.

Important: You need a Splunk APM license.

Overhead

In order to correlate database queries with Splunk APM traces, you must configure your application's instrumentation to propagate its full context to the database engine. Different database engines implement this context propagation in different ways:

  • Microsoft SQL Server: Runs SET context_info for each query, adding one additional round-trip.
  • Oracle Database: Overwrites the V$SESSION.ACTION field for each query.
  • PostgreSQL: Runs SET application_name once per session; the value applies to all subsequent queries. This is the lowest overhead.

In all cases, the propagation overhead is light and its impact on database engine performance is minimal.

Compatibility

This correlation is supported between these languages, databases, and agent/collector versions:

Language Database engine Agent/collector versions Documentation

.NET

Microsoft SQL Server
  • Splunk Distribution of OpenTelemetry .NET (splunk-otel-dotnet) v1.11.0 or later
  • Splunk Distribution of the OpenTelemetry Collector (splunk-otel-collector) v0.142.0 or later
  • Community (OSS) version of the OpenTelemetry Collector (opentelemetry-collector-contrib) v0.142.0 or later

Correlate database queries with .NET traces

Java (JDBC)

Microsoft SQL Server
  • Splunk Distribution of OpenTelemetry Java (splunk-otel-java) v2.20.1 or later
  • Splunk Distribution of the OpenTelemetry Collector (splunk-otel-collector) v0.142.0 or later
  • Community (OSS) version of the OpenTelemetry Collector (opentelemetry-collector-contrib) v0.142.0 or later

Correlate database queries with Java traces

Java (JDBC)

Oracle Database
  • Splunk Distribution of OpenTelemetry Java (splunk-otel-java) v2.20.1 or later
  • Splunk Distribution of the OpenTelemetry Collector (splunk-otel-collector) v0.142.0 or later
  • Community (OSS) version of the OpenTelemetry Collector (opentelemetry-collector-contrib) v0.142.0 or later

Correlate database queries with Java traces

Java (JDBC)

PostgreSQL
  • Splunk Distribution of OpenTelemetry Java (splunk-otel-java) v2.22.0 or later

  • Splunk Distribution of the OpenTelemetry Collector (splunk-otel-collector) v0.147.0 or later

  • Community (OSS) version of the OpenTelemetry Collector (opentelemetry-collector-contrib) v0.147.0 or later

Correlate database queries with Java traces

  1. From the Database Monitoring Overview, select a database platform instance to load the navigator for that instance.

  2. On the navigator, select Queries > Query details > Traces. See Query details.

In Splunk APM, use either the Trace Analyzer or the service map.