newrelic / newrelic-java-agent

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

Support sqlcommenter style comments #1905

Closed jbedell-newrelic closed 4 months ago

jbedell-newrelic commented 5 months ago

This is likely a problem in the Java Agent as well...

The OpenTelemetry Ruby SQL obfuscation and statement extraction code was largely a copy-paste project from the New Relic Ruby agent. While refactoring that code in open-telemetry/opentelemetry-ruby-contrib#529, we discovered statement extraction and SQL obfuscation needed some tweaking when sqlcommenter was used.

Commit where edge case was discussed: https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/529/commits/b8b2605d3cc321865a5356f66cc1bb696ca92af4 (look at resolved discussions) Commit with fix: https://github.com/open-telemetry/opentelemetry-ruby-contrib/commit/82584bae3c9132846fdd593a124dc680b770af28 This PR adds test cases to the cross-agent tests to cover sqlcommenter.

Source: https://source.datanerd.us/agents/cross_agent_tests/pull/155

workato-integration[bot] commented 5 months ago

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

jtduffy commented 4 months ago

I verified our existing SQL obfuscation code properly handles prepended SQLCommenter comments. Manually copied the new cross agent test cases into the SQLObfuscator test and all passed.

Image