AutoMerge is generally available

Last updated:

Write Custom OTTL

Run your own OTTL statements in a Custom step of a transform rule when the other step types don't cover what you need.

A Custom step runs OpenTelemetry Transformation Language (OTTL) statements you write yourself, in the rule's context. Use it for anything the other step types don't cover, for example truncating long attribute values or limiting how many attributes a record keeps.

Custom step named Truncate noisy attributes with the condition service.namespace = checkout and two OTTL statements: truncate_all(attributes, 100) and limit(attributes, 50, [])

Add a Custom Step

  1. In the rule editor, click + Transformation and set Transformation to Custom. In an empty rule, you can also click Write OTTL.
  2. Type one statement per line under OTTL statements. The statements run in order.
  3. Optionally, add a Condition to run the statements only on matching records.
  4. Check the Output panel. A statement that fails on the sample shows its error on the step, under Preview problems.

Start From Another Step

Every other step type writes OTTL, which you can see under Advanced. To edit it, change the step's Transformation to Custom: the step keeps its statements and its condition, and you can change them.

Changing a Custom step back to another type reads the OTTL again. If it matches that type, the fields are filled in. Otherwise you start from an empty step.

Example

The step above writes:

text
truncate_all(attributes, 100) where attributes["service.namespace"] == "checkout"
limit(attributes, 50, []) where attributes["service.namespace"] == "checkout"

The step's condition becomes a where clause on each statement.

Limits

  • The rule's context: The statements run in the context of the rule. For example, a statement in a Span rule can read the span, its scope, and its resource, but not its span events.
  • Checked on save: Dash0 checks the statements when you save. A statement that doesn't compile, or that uses an attribute rules may not use, blocks saving, and the step shows why.

Further Reading