Skip to content

New component: OTTL-based request partitioning processor #39199

Open
@axw

Description

@axw

The purpose and use-cases of the new component

I would like to propose a new processor for partitioning batches using OTTL. The processor would be configured with a mapping of OTTL expressions to partitioning keys, and:

  1. Infer the relevant context from the expressions (e.g. request, resource, log, datapoint, etc.)
  2. Evaluate the expressions against each batch
  3. Partition the batch according to the partitioning keys
  4. Send each batch partition to the next consumer, add the partitioning keys & values to request metadata

Some use cases below:

Topic routing and message key/partitioning for message broker exporters

The idea for this came from a PoC I implemented for routing and partitioning data before exporting to Kafka -- see #38888 (comment). This is intended to address several issues:

It's just a matter of time before users ask for the same functionality in other exporters, e.g. Pulsar.

Batching by arbitrary data and metadata attributes

In open-telemetry/opentelemetry-collector#10825 it has been suggested that the exporterhelper batch sender should be enhanced with support for batching by request metadata or by pdata attribute. The former case is simple, while the latter tends towards OTTL, so I think this would be best covered by a separate processor like this one.

General purpose "groupby" processor

Finally, this processor would provide arbitrary "group by" functionality, which could enable replacing existing processors:

(Whether we want to replace them is another matter, just saying it's a possible use case.)

Example configuration for the component

processors:
  partitioner:
    keys:
      logs_topic: Concat(request.metadata["X-Tenant-Id"]).otlp_logs
      logs_message_key: log.trace_id

In this example, requests would be partitioned by the X-Tenant-Id client request header, and data would further be partitioned by trace ID. Each partitioned batch would include the request metadata logs_topic and logs_message_key.

Telemetry data types supported

Logs, metrics, traces. When OTTL supports profiles, profiles too.

Code Owner(s)

axw

Sponsor (optional)

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Sponsor NeededNew component seeking sponsorneeds triageNew item requiring triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions