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)
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:
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
redactionalready uses it for obfuscation.currently, to collect the metadata for a query, one must use a normalizer which also normalize the SQL:
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
normalizerConfigIf you open for PR contributions, I can open a PR to add it as an option to normalizer (non-breaking, opt-in option)