-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[processor/transform] not enough preconditions to guard against warnings #23847
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Another alternative would be to adjust allow
Definitely useful to have some way to truncate string log bodies in the transform processor. |
Both suggestions sound valuable. It would be good to have a way to check the lengths of things (string, maps, slices, etc). It would also be good to have a function that can truncate strings. In the meantime, this will work and will not cause a warning when transform/newrelic:
log_statements:
- context: resource
statements:
- truncate_all(attributes, 4090)
- context: log
statements:
- truncate_all(attributes, 4090)
- set(cache["body"], body)
- truncate_all(cache, 4090)
- set(body, cache["body"]) |
@ajsaclayan @jack-berg @danelson is this something you'd like to work on? |
Technically more efficient solution: transform/newrelic:
log_statements:
- context: resource
statements:
- truncate_all(attributes, 4090)
- context: log
statements:
- set(attributes["truncate-body"], body)
- truncate_all(attributes, 4090)
- set(body, attributes["truncate-body"])
- delete_key(attributes, "truncate-body") But won't be viable if |
**Description:** Add ottl `Len` converter to make `Substring` useful for truncating. E.g.: ``` log_statements: - context: log statements: - set(body, Substring(body, 0, 10)) where Len(body) >= 10 ``` **Link to tracking Issue:** Resolves #23847. **Testing:** Unit tests, local verification with running collector. **Documentation:** Added documentation to `pkg/ottl/ottlfuncs/README.md`. This PR is the result of [conversation](#23880 (comment)) on #23880. --------- Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Component(s)
processor/transform
Is your feature request related to a problem? Please describe.
I have a transform processor configured to truncate log attributes and the body field:
This works, but the problem is when we send a
body
whose length is less than 4090 this warning message occurs:invalid range for substring function, 4090 cannot be greater than the length of target string
Describe the solution you'd like
It would be nice to be able to have a precondition like
WHERE body.Length() > 4090
to be able to guard against this warning.Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: