Skip to content

feature suggestion: collect metadata while disabling normalization #105

Description

@blumamir

Thank you for this great library, and for making it so simple and lightweight.

I have a new option I like to suggest

It is sometimes useful to keep the sql query as is, for example:

  • if users want to see the exact query sent to db for accurate instrumentation
  • have no value in normalization and prefer to save CPU cycles.

However, they may still want to collect the table names and operations. this can then be leveraged to enhance spans with attributes which are expensive to collect at instrumentation time inside the process runtime, but are good to have for usability and processing.

It can be done as an opentelemetry collector processor (similar to how redaction already uses it for obfuscation.

currently, to collect the metadata for a query, one must use a normalizer which also normalize the SQL:

		if n.shouldCollectMetadata() {
			n.collectMetadata(token, lastValueToken, meta, statementMetadata, &ctes, &inTableList)
		}
		n.normalizeSQL(token, lastValueToken, normalizedSQLBuilder, &groupablePlaceholder, &headState, &colonCtx, lexerOpts...)

of course the caller can just ignore the returned value and not use it, but the CPU cycles for normalizing are already wasted for something that ends up being dropped.

It can be useful to have an option to just collect the metadata without normalization, for example - it can be added in the normalizerConfig

If you open for PR contributions, I can open a PR to add it as an option to normalizer (non-breaking, opt-in option)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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