Last updated:
Write Custom OTTL
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.
Add a Custom Step
- In the rule editor, click + Transformation and set Transformation to Custom. In an empty rule, you can also click Write OTTL.
- Type one statement per line under OTTL statements. The statements run in order.
- Optionally, add a Condition to run the statements only on matching records.
- 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:
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
-
About Signal Transformation. Add a transform rule and learn the parts of the rule editor.
-
Check the Output. Test your statements on a sample before you save the rule.
-
OTTL Functions. The upstream reference of the editors and converters OTTL statements can call.
![Custom step named Truncate noisy attributes with the condition service.namespace = checkout and two OTTL statements: truncate_all(attributes, 100) and limit(attributes, 50, [])](/_next/image?url=%2Fimages%2Fdocumentation%2Ftelemetry%2Fsignal-control%2Ftransform%2Ftransform-step-custom.webp&w=1200&q=75&dpl=dpl_FPJLhb7pYT6acw6JGBvH9fAMdQFf)