Skip to content

Add db.query.summary to database spans #1633

@hannahramadan

Description

@hannahramadan

db.query.summary is a low-cardinality, shortened representation of a database query. It's a new, important attribute in the stable semantic conventions and will be used as the database span name under the new conventions.

db.query.summary isn't always available directly from instrumentation hooks. For these cases, we need to generate it ourselves by parsing the db.query.text.

We should implement a SQL processor that can read the db.query.text and generate a db.query.summary.

Notes:

  • Logic: The .NET implementation uses a custom built state-based parser that iterates character by character to sanitize the SQL and generate a summary. We can use this as a reference. .NET test cases.
  • Performance: Given that this processor will handle a high volume of queries, we need to consider performance. We should evaluate different methods, such as regex, string manipulation, or other approaches.
  • Logic location: We need to decide where to house this new code. Ruby has a helper gem, opentelemetry-helpers-sql-obfuscation, that contains the logic for SQL obfuscation. We could potentially rename this gem to sql-processor and add the new summary-generation logic there.

Metadata

Metadata

Assignees

Labels

keepEnsures stale-bot keeps this issue/PR open

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions