Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/ottl] Add support for lists as Getter values #16338

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

evan-bradley
Copy link
Contributor

Description:

Allow using lists as a Getter value. This implementation implements a listGetter struct that allows recursively evaluating list elements, which allows putting paths and invocations in lists.

Link to tracking Issue:

Fixes #16320

Testing:

Added unit tests to check for this functionality at multiple levels.

Documentation:

The existing docs should cover this functionality.

@evan-bradley
Copy link
Contributor Author

@TylerHelmuth This implementation is different than what we discussed, but will allow for using paths and invocations in lists. The downside is that the lists can be probably unnecessarily complicated, and we can't easily enforce that they are homogeneous, which is required by the specification for Attribute values. There are other places in the OTTL where users can cut themselves, so this seemed like an acceptable tradeoff.

@TylerHelmuth
Copy link
Member

we can't easily enforce that they are homogeneous, which is required by the specification for Attribute values

@evan-bradley I wasn't aware that array values for an attribute had to be homogenous. I was checking the spec earlier for something I was working on and this section reads to me like arrays can be a mix of values.

@TylerHelmuth
Copy link
Member

will allow for using paths and invocations in lists

This is definitely needed, good catch.

@evan-bradley
Copy link
Contributor Author

I wasn't aware that array values for an attribute had to be homogenous. I was checking the spec earlier for something I was working on and this section reads to me like arrays can be a mix of values.

When working on this, I found two places where the proto AnyValue was used:

  • Attribute values that are arrays are required to be homogeneous arrays by the specification. While OTLP does support heterogeneous arrays for attribute values, the API implementations will only accept and emit attribute values that are homogeneous arrays.
  • Logs support heterogeneous arrays in the body field to support existing log models, but advises a string type for new implementations.

I would prefer that the Collector didn't intentionally emit any data in a format that would be disallowed for an OpenTelemetry language API, since it is likely for data that isn't spec-compliant to be handled inconsistently or simply dropped by backends. I don't think the Collector is technically bound to abide by the specification to that degree, so I don't think we are required to do anything in this case.

I think if we do decide to validate that attributes are only set to homogeneous arrays, we should probably do it in the contexts.

@TylerHelmuth
Copy link
Member

Good info, thanks for pointing out those API requirements. I agree, we should follow the spec so we don't produce any invalid data.

I agree that the contexts should be the enforcers. Within the contexts there are no Getters, just values, so it should be easy to check and enforce.

Can you open an issue to track this enforcement?

Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@evan-bradley
Copy link
Contributor Author

Can you open an issue to track this enforcement?

See #16355.

@bogdandrutu
Copy link
Member

Needs a rebase

@TylerHelmuth TylerHelmuth added the ready to merge Code review completed; ready to merge by maintainers label Nov 21, 2022
@bogdandrutu bogdandrutu merged commit c33fa32 into open-telemetry:main Nov 23, 2022
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2022
Add support for lists as Getter values

Co-authored-by: Evan Bradley <[email protected]>
@plantfansam plantfansam mentioned this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/ottl processor/transform Transform processor ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pkg/ottl] Unable to use ottl lists in a Getter
4 participants