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. SolarWinds recommends 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 |
Notes |
---|---|---|
MySQL |
Hibernate (prepared statements) version 4+ |
The MySQL Connector/J driver by default emulates prepared statements on the client side, and does not cache (see If both caching and server-side prepared statements are enabled in the driver, enabling Queries with short-lived connections might not be sampled due to MySql Performance Schema behavior. |
PostgreSQL |
Hibernate (prepared statements) version 4+ |
The PostgreSQL JDBC driver by default caches and enables server-side prepared statements. Enabling Short-lived queries, or queries with short-lived connections might not be sampled based on the DBO Agent's polling interval. |