open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
3.11k stars 2.39k forks source link

[OTTL] Fix empty string matching for replace_all_patterns #36408

Open pkcll opened 1 week ago

pkcll commented 1 week ago

Fix empty string matching for replace_all_patterns, replace_all_matches OTTL functions

Description

OTTL functions replace_all_patterns, replace_all_matches apply pattern matching on all attribute values including non string types by casting value to string using value.Str() method (see here, here) . For non string types Str() returns empty string. In case when empty string patterns is used that creates unintended side effect when pattern matching is applied for non string types.

Example:

Current behavior:

Expected behavior:

Testing

Added new test case here and here

linux-foundation-easycla[bot] commented 1 week ago

CLA Not Signed

evan-bradley commented 1 week ago

Thanks for opening this @pkcll. I agree this is an issue since replace_pattern and replace_match both check that the target is a string before working with it.

Could you please sign the CLA?

pkcll commented 1 week ago

@evan-bradley

Could you please sign the CLA?

Will do shortly. Let me double check which one should I sign individual CLA or corporate