The sqlparamstyle processor is a custom component: it is not included in the standard OpenTelemetry Collector distribution.
To use it you build your own collector binary that includes this processor, then run that binary with a config that enables the processor in a pipeline.
This guide walks you through that in order: configure the processor (runtime config), configure the custom collector (which components to bake into the binary), build the binary, and run it.
You need a collector config file that defines pipelines and enables the sqlparamstyle processor.
The processor normalizes parameterized SQL in span attributes (e.g. db.statement) so traces group by query shape instead of literal values.
File: examples/collector-config.yaml
Relevant parts:
- Processors:
sqlparamstylewith:attribute_keys: list of span attribute names to normalize (e.g.db.statement).normalize_in_clause: iftrue, reducesIN (?, ?, ?)to a single placeholder for better grouping.
- Pipeline: a traces pipeline that uses
sqlparamstyle(and e.g.batch) between receivers and exporters.
processors:
sqlparamstyle:
attribute_keys:
- db.statement
normalize_in_clause: true
batch:
timeout: 10s
service:
pipelines:
traces:
receivers: [otlp]
processors: [sqlparamstyle, batch]
exporters: [debug]You will pass this file to the collector when you run it (step 4). No changes are required for the rest of this guide; you can edit it later to add receivers/exporters or tune the processor.
Because the processor is not in the default distribution, you define a custom distribution by listing the components to include. The OpenTelemetry Collector Builder reads a manifest and generates a Go project that compiles to a single binary containing only those components.
File: examples/builder-config.yaml
dist: name of the binary (custom-otelcol), output directory (./dist), and optional module/version/otelcol version.receivers/processors/exporters: list of components. Core components are pulled bygomod(e.g.batchprocessor,otlpreceiver). This repo's processor is included as a processor component, either via a published module or a local checkout:
processors:
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.147.0
- gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.147.0
# sqlparamstyle: PEP 249 paramstyle normalization for trace attribute_keys (e.g. db.statement)
- gomod: github.com/nilox94/otel-sqlparamstyle-processor v0.1.0Use the gomod: github.com/nilox94/otel-sqlparamstyle-processor v0.1.0 line to depend on a published version of this processor.
To build against a local checkout instead, add a path field to the same processor entry:
- gomod: github.com/nilox94/otel-sqlparamstyle-processor v0.1.0
path: /path/to/otel-sqlparamstyle-processorInstall the Collector Builder (if you haven't already).
It is published as the builder binary when installed via Go:
go install go.opentelemetry.io/collector/cmd/builder@v0.147.0From the repository root, run the builder with the manifest from step 2:
builder --config=examples/builder-config.yamlWhen it finishes, the custom collector binary is at:
./dist/custom-otelcol
Start the collector with the runtime config from step 1:
./dist/custom-otelcol --config=examples/collector-config.yamlSend traces whose spans have parameterized SQL in the configured attributes (e.g. db.statement).
The sqlparamstyle processor will normalize placeholder styles and, if normalize_in_clause is enabled, collapse IN lists so that traces group by query shape.