newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
202 stars 144 forks source link

Discrepancy in how SQL queries are captured / truncated in different areas of APM #2079

Open JesseLaughlin opened 1 month ago

JesseLaughlin commented 1 month ago

Description

SQL queries displayed on the Datastores page in APM are truncated at 2,000 characters by default, as per https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#insert_sql_max_length

However, SQL queries displayed on the Transaction Trace SQL queries tab are not. More specifically, they are truncated only if the statement is an insert: https://github.com/newrelic/newrelic-java-agent/blob/070842710cd23b460c0bb3c0492b52c0fd3e576b/newrelic-agent/src/main/java/com/newrelic/agent/trace/TransactionSegment.java#L255

Expected Behavior

We would expect that SQL queries would be treated the same way throughout the product. If they are not, the intuitive location to display the complete, untruncated SQL query is the Datastores slow query page.

Troubleshooting or [NR Diag]

In internal discussions, we identified the following discrepancies:

It also appears that not all of our APM agents limit SQL query size in the same way. Additional work is needed to determine if this is consistent with agent specification.

workato-integration[bot] commented 1 month ago

https://new-relic.atlassian.net/browse/NR-320677

kford-newrelic commented 1 month ago

Suggested enhancement will be evaluated but this is not a bug.