Documentation forSolarWinds Observability SaaS

Java trace context in queries

Adding trace context to application queries provides the ability to correlate the queries from a traced transaction, and if sampled, the queries to the transaction trace detail. This feature is also a requirement for the integration of APM with DBO.

Enabling

Trace context propagation to queries is disabled by default. It can be enabled in the Java Library using these configuration options:

  • agent.sqlTag: Set to true to enable context insertion for non-prepared statements.

  • agent.sqlTagPrepared: Set to true to enable context insertion for prepared statements.

    The trace context injected for prepared statements will only be correct for database interactions through Hibernate. Depending on the database driver settings for caching and server-side prepared statements, injecting the unique trace context could incur extra overhead and performance penalty. SolarWindsrecommends enabling injection for prepared statements only after checking the impact on your system.

  • agent.sqlTagDatabases: This option should be used to restrict context insertion to the database(s) relevant to the instrumented application.

Support Matrix

Trace context is inserted only for statements from a transaction sampled for detailed tracing.

Database type

Client library/framework

Versions supported

Notes
MySQL

JDBC

Hibernate (prepared statements) version 4+

The MySQL Connector/J driver by default emulates prepared statements on the client side, and does not cache (see cachePrepStmts) or enable server-side prepared statements (see useServerPrepStmts). In this case enabling agent.sqlTagPrepared should have little overhead and performance penalty.

If both caching and server-side prepared statements are enabled in the driver, enabling agent.sqlTagPrepared would cause each statement to be treated as new, increasing cache memory use and database prepare calls. The overhead and performance penalty should be evaluated carefully before enabling this option.

PostgreSQL

JDBC

Hibernate (prepared statements) version 4+

The PostgreSQL JDBC driver by default caches and enables server-side prepared statements. Enabling agent.sqlTagPrepared would cause each statement to be treated as new, increasing cache memory use and database prepare calls. The overhead and performance penalty should be evaluated carefully before enabling this option.