Skip to content

[pkg/ottl] unexpected behavior of flatten function when handling slice attributes at top level #36161

Closed
@bacherfl

Description

@bacherfl

Component(s)

pkg/ottl

What happened?

Description

Currently, when setting the depth to 0, slices at the top level of the input of the flatten function will still be flattened.

Steps to Reproduce

Consider the following input for the flatten function:

{
  "things": [
    {
       "name": "a"
    }
  ]
}

And use the flatten function with a depth of 0:

flatten(attributes, depth=0)

Expected Result

According to the docs, there should be no flattening when the depth is set to 0, i.e. the input should be left unchanged:

{
  "things": [
    {
       "name": "a"
    }
  ]
}

Actual Result

The slice elements are flattened, regardless of the depth

{
  "things.0": {
    "name": "a"
  }
}

Collector version

v0.112.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions