beats icon indicating copy to clipboard operation
beats copied to clipboard

[OTel Mapper] Fails to convert nested arrays and slices to `[]any`

Open pickypg opened this issue 6 months ago • 2 comments

Prior to shipping Beat events to OTel via the otelconsumer, Beats attempts to sanitize the mapstr.M map for the pdata library used by OTel.

The sanitization does a few key things, but it serves two wide-reaching purposes:

  1. Convert mapstr.M to map[string]any in place.
    • pdata inherently does not know about mapstr.M
  2. Convert arrays and slices (including []mapstr.M) to []any.
    • pdata choose to not work with other types.

However, with both purposes, there are two issues:

  1. It recursively handles mapstr.M, but it does not recursively handle map[string]any. Any nested slices / arrays within a map[string]any will inevitably fail to be handled by pdata unless they happen to already be []any slices. And, in the unlikely event of a mapstr.M containing a map[string]any containing a mapstr.M, the inner mapstr.M would not be converted.
  2. It does not actually convert arrays because it only uses the switch to detect slices.

pickypg avatar Jun 24 '25 18:06 pickypg

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

elasticmachine avatar Jun 24 '25 20:06 elasticmachine