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/stanza] Add 'regex_replace' operator #37443

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

gjasny
Copy link
Contributor

@gjasny gjasny commented Jan 23, 2025

Description

We use the filelog receiver to ingest Artifactory logs. Some but not all of them contain ANSI color sequences. This makes regex creation pretty uncomfortable because both: log field separators and the ANSI color codes contain [ characters.

I was first thinking about using the add operator and removing the regex within the EXPR(). But I could not find any suitable regex function which works within that expression.

I could imagine that I'm not the only one who would like to get rid of colors. Therefore I believe that an easy to use operator enhances readability of the pipeline and is less error-prone than a (potentially) hand-crafted regex.

Testing

Added unit tests and tested locally against Artifactory log files.

@gjasny gjasny requested review from djaglowski and a team as code owners January 23, 2025 14:13
@gjasny gjasny force-pushed the strip-ansi-escape-codes branch from b32fac5 to 411655a Compare January 23, 2025 14:15
atoulme
atoulme previously approved these changes Jan 24, 2025
Copy link
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

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

This is a neat enhancement, thank you. I have reviewed the code and approve it, the codeowners have last word on accepting it.

Copy link
Contributor

github-actions bot commented Feb 8, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 8, 2025
@gjasny
Copy link
Contributor Author

gjasny commented Feb 8, 2025

@djaglowski Could you please take a look? I used mostly the "unquote" operator as a blueprint. So there should not be any surprises.

Thanks!

@github-actions github-actions bot removed the Stale label Feb 9, 2025
@atoulme atoulme dismissed their stale review March 5, 2025 00:29

dismiss as more work is required

@gjasny gjasny force-pushed the strip-ansi-escape-codes branch from 411655a to 0af4984 Compare March 6, 2025 14:17
@djaglowski djaglowski changed the title [pkg/stanza] Add 'strip_ansi_escape_codes' operator [pkg/stanza] Add 'regex_replace' operator Mar 7, 2025
@djaglowski djaglowski merged commit 45b4cb4 into open-telemetry:main Mar 7, 2025
157 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 7, 2025
@gjasny gjasny deleted the strip-ansi-escape-codes branch March 7, 2025 16:35
gjasny added a commit to gjasny/opentelemetry-collector-contrib that referenced this pull request Mar 8, 2025
gjasny added a commit to gjasny/opentelemetry-collector-contrib that referenced this pull request Mar 8, 2025
This is a follow-up from open-telemetry#37443. It extracts the test logic for
operator build errors into re-useable methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants