Description
Description:
Currently, the OpenTelemetryTraceEventListener
enriches spans with valuable metadata such as SQL operation, connection ID, and database user. However, the addition of sensitive information, such as Original SQL Text and Actual SQL Text (enabled by the OPEN_TELEMETRY_TRACE_EVENT_LISTENER_SENSITIVE_ENABLED
flag), raises concerns about exposing sensitive data in trace spans.
Proposed Feature:
I propose adding support for SQL statement sanitization in the OpenTelemetryTraceEventListener
. This feature would allow users to include SQL statements in spans while masking sensitive information, such as literal values, without compromising visibility into database interactions.
Sanitization Capability:
- Introduce a mechanism to sanitize SQL statements before adding them to spans.
- Replace sensitive literals (e.g., numbers, strings, dates) with placeholders (?) while retaining the query structure.
Example:
- Original SQL: SELECT * FROM users WHERE id = 123 AND name = 'John';
- Sanitized SQL: SELECT * FROM users WHERE id = ? AND name = ?;
I am happy to contribute to this feature and provide an initial implementation if the maintainers agree on its inclusion. Please let me know your thoughts!