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

feat(ottl): Add a new ottl trim function that trims leading and trailing whitespace from a string #36400

Merged
merged 10 commits into from
Dec 20, 2024

Conversation

rnishtala-sumo
Copy link
Contributor

@rnishtala-sumo rnishtala-sumo commented Nov 16, 2024

Description

A field test exists in an event, which contains the string " this is a test ".

I would like to be able to transform this using an ottl function trim, that I would define as trim(attribute["test"]), which would trim this down to "this is a test".

  • Trim(" this is a test ") results in this is a test

Link to the issue - #34100

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.

Please add an entry to ottlfuncs/README for this new converter

@TylerHelmuth
Copy link
Member

@rnishtala-sumo can you add to the description the issue this PR closes

.chloggen/ottl-trim-function.yaml Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/func_trim.go Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/README.md Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/README.md Outdated Show resolved Hide resolved
pkg/ottl/ottlfuncs/func_trim.go Outdated Show resolved Hide resolved
@TylerHelmuth TylerHelmuth added the ready to merge Code review completed; ready to merge by maintainers label Dec 20, 2024
pkg/ottl/ottlfuncs/README.md Outdated Show resolved Hide resolved
@TylerHelmuth TylerHelmuth merged commit b600350 into open-telemetry:main Dec 20, 2024
161 checks passed
@github-actions github-actions bot added this to the next release milestone Dec 20, 2024
AkhigbeEromo pushed a commit to sematext/opentelemetry-collector-contrib that referenced this pull request Jan 13, 2025
…ing whitespace from a string (open-telemetry#36400)

#### Description

A field test exists in an event, which contains the string " this is a
test ".

I would like to be able to transform this using an ottl function trim,
that I would define as trim(attribute["test"]), which would trim this
down to "this is a test".

- Trim(" this is a test ") results in `this is a test`

Link to the issue -
open-telemetry#34100

---------

Co-authored-by: Tyler Helmuth <[email protected]>
Co-authored-by: Evan Bradley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contribfest pkg/ottl ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants