Skip to main content

Considerations

Before enabling DB query templatization, please note the following:
  • The action rewrites db.query.text (or the deprecated db.statement) in place when present.
  • Number and string literals are replaced with ?. Identifiers, bind/positional parameters, booleans, and NULL are left unchanged.
  • Spans without a db.system.name (or the deprecated db.system) attribute, or with a known non-SQL system (e.g. MongoDB, Redis), are skipped.

Use Cases

Cardinality control
  • Raw SQL with embedded literals (e.g. WHERE id = 1 vs WHERE id = 2) creates high-cardinality query attributes and span names. Templatizing literals collapses those into a shared template such as WHERE id = ?.
Cost and backend indexing
  • Lower cardinality on database spans improves aggregations, span metrics, and indexing in your observability backend, and can reduce storage volume.
Sensitive values in queries
  • Replacing string and number literals removes many accidental secrets or PII that were inlined into SQL (passwords, emails, IDs) while keeping the query structure intact.

Configuration Options

The DbQueryTemplatization action is configured using the odigos.io/v1alpha1.Action CRD with the dbQueryTemplatization configuration section.
actionName string : Allows you to attach a meaningful name to the action for convenience.
  • This field is optional
  • Odigos does not use or assume any meaning from this field
notes string : Allows you to attach notes regarding the action for convenience.
  • This field is optional
  • Odigos does not use or assume any meaning from this field
disabled boolean : Allows you to temporarily disable the action, but keep it saved for future use.
  • This field is optional, and defaults to false
signals string[] : An array with the signals that the action will operate on.
  • This field is required
  • Supported values: TRACES
dbQueryTemplatization object : Configuration for the DbQueryTemplatization action.
  • This field is required for this action type
scopes object : Limits which sources this templatization config applies to.
  • This field is optional
  • If unset or empty, the config is applied to all sources.
  • If multiple source scopes are set, they must all match simultaneously (AND logic).
sources object[] : A list of workloads to apply this action to.
  • Each entry requires name, namespace, and kind (Deployment, StatefulSet, etc.).
namespaces string[] : Apply this action to all sources in the listed namespaces.
languages string[] : Apply this action only to containers instrumented with the listed programming languages.
templatizeLiterals boolean : When enabled, number and string literals in SQL queries are replaced with placeholders.
  • This field is optional, and defaults to false
  • What is templatized:
    • number literals (e.g. 1, 3.14)
    • string literals (e.g. 'alice')
  • What is not templatized:
    • identifiers (table names, column names, etc.)
    • positional parameters (e.g. $1)
    • bind parameters (e.g. :name)
    • boolean literals and NULL
    • keywords, operators, punctuation, whitespace, comments, etc.

Basic Example

Given a span with:
the action rewrites it to:
1
Create a YAML file with the following content:
db-query-templatization.yaml
2
Apply the action to the cluster:

Scoped Example

To limit templatization to specific workloads, add scopes. Omit scopes (or leave it empty) to apply the action to all sources.
db-query-templatization-scoped.yaml
Pair this action with Infer DB Attributes so database spans get both templatized query text and inferred db.operation.name / db.collection.name attributes.