Correlate database queries with Splunk APM traces

Correlate database queries with Splunk APM traces from a .NET application.

Correlating database queries with APM traces in Splunk Observability Cloud delivers significant troubleshooting benefits. With this integration, you can map a slow or problematic database query observed on the client side to its originating request in an application. This end-to-end visibility allows you to pinpoint exactly where latency or errors occur, whether in the application layer, during query transmission, or within the database itself.

By seamlessly navigating from a specific query in Database Monitoring to related spans in Splunk APM, you eliminate the guesswork of matching database queries and traces manually. This streamlines root cause analysis, reduces mean time to resolution (MTTR), and enables faster identification of inefficient queries or resource bottlenecks affecting customer experience.

Additionally, trace and query correlation empowers teams to prioritize remediation efforts and proactively optimize database performance. Understanding the full path of a query (across services, networks, and database internals) supports data-driven decisions for tuning workloads and improving reliability.

After you set up this correlation, select Queries > Query details > Traces to navigate from normalized queries to APM traces.

Note:

Overhead for APM trace and database query correlation: To enable correlation between APM traces and database queries, you must enable database context propagation in your application's instrumentation. When enabled, your application's instrumentation sends full trace information to the database, allowing you to investigate individual traces alongside database activity. The implementation of trace propagation varies by database engine:

  • Microsoft SQL Server database engines execute a SET context_info command for each query, resulting in an additional round-trip to the database.

  • Oracle Database engines overwrite the V$SESSION.ACTION field for each query.

Although enabling context propagation introduces additional calls to the database engine, the associated overhead is typically very light and should have minimal impact on performance.

Note:

About database query samples: Propagated span or trace information is available only for query samples. By default, the OpenTelemetry Collector’s database receiver collects query samples every 10 seconds. Only those APM traces that correspond to queries captured as samples will have correlation data recorded. Many other traces may not have this correlation present.

Compatibility

This correlation is supported between these agents and collectors:

License requirements

To configure this correlation, you must have a Splunk APM license and you must update the instrumentation on the supported applications.