-
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
A new ottl function/editor to replace a regex pattern match with its hash value or digest #22787
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
OTTL has no way to accept a converter as a parameter, it will always execute the converter first and use the value returned. If we want to do either of the proposed strategies we'd need to update the grammar and the parser. If we went with |
There currently seems to be one example of a function/editor that accepts a converter as a parameter as below Example: where
So can we not follow a similar pattern for a new hash function/editor? |
Converts can be used in parameters, but they are executed before the main function is executed. In that example For this issue, in order for the capture group logic to work, the literal Converter function would need passed into the |
Considering the above limitation with passing a converter function, could we do this instead for the first iteration?
|
I would prefer to solve this via #20879, #22961 and It is extra work, but finishing off those 2 issues first will provide the best end-user experience, reduce breaking changes, and reduce tech debt. |
For extra clarity, resolving the 2 issues linked above will allow all existing users of The function already allows looking through all the attribute values for a specific pattern and then changing them dynamically based on those values; adding in extra manipulation to that action feels reasonable to enable flexible and complex transformations. Open question: should the optional parameter accept a list of converters or can that functionality be handled via multiple statements? I believe accepting a list would be more efficient. |
We should also highlight in the function's documentation that the extra converters only need to be used if you are using capture groups. If you are replacing patterns with static values you can use the existing converter logic: |
A list of converters could be useful, but what about the scenario below:
Both the converters accept different mandatory input parameters. Could this be an issue? We could then limit the list to only converters that take one input parameter, for example:
In the above example we first apply |
Ya those are definitely concerns that will need to be worked through for #22961. The ability to pass a convert to a function may need to be "typed" so that the functions accepting them as parameters can set expectations. Hopefully a strategy similar to |
Also currently,
In the above, we're replacing the device name using an attribute field. |
@rnishtala-sumo yes I think we can allow the replacement value to come from another attribute using |
ok great, I can raise a PR for this soon, supporting this would allow the user to
The above could be used to hash a device name in a log like below not ideal/hacky maybe, but would love to hear thoughts on this. |
Created the following PR for review based on the above discussion #23210 |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
**Description:** Functions to modify matched text during replacement can now be passed as optional arguments to the following Editors: - replace_pattern - replace_all_patterns - replace_match - replace_all_matches **Documentation:** https://github.com/rnishtala-sumo/opentelemetry-collector-contrib/blob/ottl-replace-pattern/pkg/ottl/ottlfuncs/README.md#replace_pattern **Issue:** Resolves #22787
…etry#27235) **Description:** Functions to modify matched text during replacement can now be passed as optional arguments to the following Editors: - replace_pattern - replace_all_patterns - replace_match - replace_all_matches **Documentation:** https://github.com/rnishtala-sumo/opentelemetry-collector-contrib/blob/ottl-replace-pattern/pkg/ottl/ottlfuncs/README.md#replace_pattern **Issue:** Resolves open-telemetry#22787
…etry#27235) **Description:** Functions to modify matched text during replacement can now be passed as optional arguments to the following Editors: - replace_pattern - replace_all_patterns - replace_match - replace_all_matches **Documentation:** https://github.com/rnishtala-sumo/opentelemetry-collector-contrib/blob/ottl-replace-pattern/pkg/ottl/ottlfuncs/README.md#replace_pattern **Issue:** Resolves open-telemetry#22787
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
This function/editor would be used to replace substrings (identified with a regex pattern) with a hash value/digest
Describe the solution you'd like
There could be two approaches to this:
replace_all_patterns
editorreplace_all_patterns(target, mode, regex, sha1(replacement))
Please refer to: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#replace_all_patterns
hash_all_patterns(target, mode, regex, sha1(replacement))
Which is similar to
replace_all_patterns
, but accepts aconverter
as the last argument.Describe alternatives you've considered
None exist.
Additional context
#22725 (comment)
No response
The text was updated successfully, but these errors were encountered: