AutoMerge is generally available

Last updated:

Set Attributes

Add an attribute or overwrite a value with a Set step in a transform rule, for example to tag records with an environment or fix a span status.

A Set step sets an attribute or an OTLP field to a value. It creates the attribute when it is missing and overwrites it otherwise. Use it to enrich records, for example to tag every record from a service with its environment, or to change a field such as a span's status.

Set step that sets the resource attribute deployment.environment to production, with Insert only checked, and the OTTL it writes

Add a Set Step

  1. In the rule editor, click + Transformation. New steps start as Set. You can also hover an attribute in Input sample data, click Add a transformation step, and pick Set. To add a new attribute, click Add an attribute with a transformation step next to a section of the sample.
  2. Fill in the fields:
  • Target context: Where to write: Resource, Scope, or the record, such as Span or Log record.
  • Target attribute: The attribute to set, for example deployment.environment.name. To set a field of the record, use its otel. key, for example otel.span.status.code.
  • Value: The value to write.
  • Insert only: Only set the attribute when it has no value yet. Otherwise an existing value is overwritten.
  1. Check the Output panel: the attribute shows as added, or as modified with its previous value.

Values

Dash0 reads the type of the value from what you type:

  • Numbers: 42 and 0.5 are written as numbers.
  • Booleans and empty values: true, false, and nil are written as is.
  • Field values: On an OTLP field, a value such as STATUS_CODE_ERROR or SEVERITY_NUMBER_WARN is written as that field's value.
  • Text: Anything else is written as text, for example production or GET.

Set step that sets the span field otel.span.status.code to STATUS_CODE_ERROR, without an Insert only option

The fields you can set are:

  • Spans: otel.span.name, otel.span.kind, otel.span.status.code, and otel.span.status.message.
  • Logs: otel.log.body, otel.log.severity_number, and otel.log.severity_text.
  • Metrics: otel.metric.name, otel.metric.unit, and otel.metric.description.

Insert only isn't available on fields, because a field always has a value.

Example

Setting deployment.environment.name on the resource to production, with Insert only, writes this OpenTelemetry Transformation Language (OTTL) statement:

text
set(resource.attributes["deployment.environment.name"], "production") where resource.attributes["deployment.environment.name"] == nil

Further Reading