Skip to main content
Now let’s take a closer look at the OpenTelemetry Transformation Language (OTTL) — what it is, why it matters, and how it integrates with the OpenTelemetry Collector pipeline. OTTL lets you write concise, expressive rules that the Collector evaluates as telemetry flows through processors. These rules can enrich, normalize, redact, or filter traces, metrics, and logs so exporters receive safer and more consistent data.
The image depicts a diagram titled "Transforming Telemetry Signals with OTTL," illustrating the transformation of incoming telemetry signals into traces, metrics, and logs.
What OTTL does in a nutshell
  • Define rules (statements) in processor configurations.
  • The Collector evaluates those statements per telemetry item.
  • Statements can set attributes, replace values, extract patterns, or drop items.
  • Works across all signal types: traces, metrics, and logs.
OTTL integrates into the Collector pipeline so transformations happen inline — before data is routed to sinks/exporters or other processing steps.
The image is a flowchart showing how OTTL fits into the processing pipeline, illustrating the transformation of traces, metrics, and logs through changes, filters, and transforms, resulting in processed data.
Common use cases
  • Remove or mask sensitive data (PII) before export.
  • Add, rename, or normalize attributes for schema consistency.
  • Filter out noisy or irrelevant telemetry to reduce volume.
  • Extract or combine fields to simplify downstream analysis.
The image lists four common use cases for OTTL: removing sensitive data, adding or renaming fields, filtering out unwanted data, and combining multiple fields.
Collectors, processors, and connectors that use OTTL Several Collector components embed OTTL support so you can apply rules in different stages:
ComponentPurposeExample usage
Transform processorModify telemetry as it flowstrace_statements to set or update attributes
Filter processorDrop unwanted telemetryDrop spans from non-prod environments
Tail-sampling processorSelect spans for samplingKeep only error-related traces
Routing connectorRoute data between pipelinesSend logs to a pipeline based on attributes
The image displays four types of processors and connectors that use OTTL: Transform Processor, Filter Processor, Tail Sampling Processor, and Routing Connector, with brief descriptions of each.
Practical examples Below are common, real-world examples that show how OTTL statements are written and what outcomes they produce. Each example includes an input span, the OTTL statements (as used in a transform/filter processor), and the resulting span or traces after processing. Example 1 — Set severity from HTTP status
  • Input span (before):
  • Transform processor (OTTL) statements:
  • Resulting span (after):
This shows how to enrich spans by adding a severity attribute derived from http.status_code. Example 2 — Extract values and parse user agent
  • Input span:
  • Transform processor (extract user ID and device type):
  • Resulting span (after):
Example 3 — Hashing (redacting) sensitive attributes
  • Input span:
  • Transform processor (hash sensitive fields using a hashing function):
Note: function names and availability vary across Collector distributions. The intent is to replace raw PII with consistent hashes for safe correlation.
  • Resulting span (after — sample hashed values shown):
Example 4 — Drop fast or non-production spans with the filter processor
  • Input traces payload:
  • Filter processor rule (drop fast or non-prod spans):
The filter processor drops spans that match the condition — in this case, fast spans or spans not in env == "prod".
  • Resulting traces (after):
How OTTL statements execute
  • Statements live inside transform/filter configurations (e.g., under trace_statements).
  • set() specifies the target attribute or field to change.
  • where is a guard — run the statement only when the condition is true.
  • If the where condition is false, the statement is skipped for that telemetry item.
Error handling modes OTTL execution supports different error modes that influence Collector behavior when a statement fails:
ModeBehaviorWhen to use
IgnoreLog the error and continue processingSafe default for production; keeps pipeline running
SilentContinue without logging the errorRarely recommended — hides issues
PropagateSurface the error and stop processingUse when you must prevent any bad transformations from being applied
The image is a table outlining error handling modes in OTTL execution, with descriptions for "Ignore," "Silent," and "Propagate" modes.
Recommendation: use error_mode: ignore during exploration to avoid dropping data due to rule mistakes. Switch to error_mode: propagate when you require strict enforcement that prevents any erroneous transformation from being applied. Simple processor snippets
  • Transform processor for logs (ignore minor errors):
  • Filter processor example to drop spans from service1:
Best practices and validation
Start small: add one simple OTTL statement and test it. Use error_mode: ignore while iterating, then switch to stricter error handling once your rules are stable. Always validate your Collector configuration before deploying.
Validate the Collector configuration after edits:
This command helps catch syntax errors and common configuration problems before you roll out changes. Further reading and references That covers the core OTTL concepts: purpose, placement in the Collector pipeline, common use cases, hands-on examples for enrichment/redaction/filtering, error handling options, and validation tips.

Watch Video