opentelemetry-java-instrumentation icon indicating copy to clipboard operation
opentelemetry-java-instrumentation copied to clipboard

Don't cache sanitization results for large sql statements

Open laurit opened this issue 9 months ago • 0 comments

Hopefully resolves https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13180 Since we keep the statement as key in the sanitization cache large statements can cause the cache to grow to several hundred mb in size. This PR disables caching for statements larger than 10kb. There isn't any particular reason why 10kb was chosen so feel free to suggest a different size. Besides disabling the cache this PR introduces a thread local context for sharing computed values between span name extract and attribute extractor for sql client calls. This allows us to sanitize each statement only once and reuse the result between span name and attribute extraction.

laurit avatar Feb 19 '25 14:02 laurit