-
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
[pkg/ottl] OTTL Sprintf Function #33405
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I think this makes sense. It should be fairly easy to implement, we already have a untyped getter ( |
**Description:** This adds in a converter that calls `fmt.Sprintf` with a format string and a set of arguments. **Link to tracking Issue:** #33405 **Testing:** Added in a couple of unit tests **Documentation:** Added the new converter to the functions readme Signed-off-by: sinkingpoint <[email protected]>
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. |
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
When using OTTL, it's often useful to be able to construct strings in various ways. We do have a few ways of doing this already (e.g.
Concat
), but nothing as flexible as a genericSprintf
. For example, we have no way of padding ints (%02d
in Sprintf)Describe the solution you'd like
I would like to introduce a new OTTL function,
Sprintf
which takes a format string, and an array of fields, and callsfmt.Sprintf
with those arguments.This would require introducing a new
Getter
which gets a genericinterface{}
, rather than the existing Getters which return concrete types.Describe alternatives you've considered
We can sort of get there with creative uses of
Concat
, but this quickly becomes unruly with complex definitions. e.g. this is one we have:Which would look like:
Additional context
No response
The text was updated successfully, but these errors were encountered: