opentelemetry-java-instrumentation
opentelemetry-java-instrumentation copied to clipboard
Don't cache sanitization results for large sql statements
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.