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] IsMatch works on maps and slices in contradiction to documentation #19652

Closed
swiatekm opened this issue Mar 14, 2023 · 3 comments
Closed
Labels
bug Something isn't working pkg/ottl priority:p3 Lowest

Comments

@swiatekm
Copy link
Contributor

Component(s)

pkg/ottl

What happened?

Description

According to documentation IsMatch should return false for non-atomic types:

The function matches the target against the pattern, returning true if the match is successful and false otherwise. If target is a boolean, int, or float it will be converted to a string. If target is nil or not a string, boolean, int, or float false is always returned.

In reality, it serializes maps and slices to a string using JSON: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/ottlfuncs/func_is_match.go#L56

Both the documentation and the code were added in the same PR (#16503) so I'm not sure what is actually intended, but the documented behavior makes more sense to me.

Collector version

v0.73.0

Environment information

No response

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

What I'm actually trying to do is detect if a value is a map, so if there's a simpler way of doing that, I'd appreciate some guidance.

@swiatekm swiatekm added bug Something isn't working needs triage New item requiring triage labels Mar 14, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@TylerHelmuth TylerHelmuth added priority:p3 Lowest and removed needs triage New item requiring triage labels Mar 14, 2023
@TylerHelmuth
Copy link
Member

TylerHelmuth commented Mar 14, 2023

@swiatekm-sumo thanks for finding this discrepancy. With the new concept of typed-getters I think this lets itself to using a StringLikeGetter in the future, so I would opt for the code being accurate and the documentation being inaccurate. If we are willing to convert 1 data type to a string it seems reasonable to convert any supported datatype to a string.

@swiatekm
Copy link
Contributor Author

Allright, let's just update the documentation then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg/ottl priority:p3 Lowest
Projects
None yet
Development

No branches or pull requests

2 participants