Skip to content

Add Support for SQL Statement Sanitization in OpenTelemetryTraceEventListener #132

Open
@agent-adam

Description

@agent-adam

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions