alloy icon indicating copy to clipboard operation
alloy copied to clipboard

Add `conditions` support to `otelcol.processor.transform` from upstream OpenTelemetry `transformprocessor`

Open justinbwood opened this issue 6 months ago • 0 comments

Request

Alloy's otelcol.processor.transform component is currently missing support for conditions from the upstream transformprocessor

Example of conditions in transform processor:

transform:
  error_mode: ignore
  metric_statements:
    - context: metric
      conditions: 
        - type == METRIC_DATA_TYPE_SUM
      statements:
        - set(description, "Sum")

What the equivalent should look like in Alloy:

otelcol.processor.transform "example" {
  error_mode = "ignore"
  metric_statements {
    context = "metric"
    conditions = [
      `type == METRIC_DATA_TYPE_SUM`,
    ]
    statements = [
      `set(description, "Sum")`,
    ]
  }
  output {
    metrics = [...]
  }
}

Use case

If a block of statements has a common set of conditions, it would be useful to skip processing of that entire block of statements, rather than have to copy/paste that condition onto every statement.

In some cases where a block contains many transforms that only apply in certain conditions, it could improve transform processing time by reducing the number of operations.

justinbwood avatar Aug 11 '24 20:08 justinbwood