-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Some functions are marked as pure in the docs but don't really follow the widely accepted definition of a pure function. Some functions don't alter the underlying event but the return won't be identical for identical arguments for example.
The definition of purity in the Vector docs probably should be expanded to match the commonly accepted definition.
If we update the definition of purity in the VRL docs, then the following functions will also need to be updated:
now(): which will return different values depending on when it's called.uuid_v7(): callsnow()implicitlyfind_vector_metrics: will return different values once metrics refresh- all other metrics related functions
get_secret: depends on the underlying event's secrets- and maybe more...
A purity audit of functions would be needed, specially those exclusively present in Vector.
We can also optionally also expand what purity means in Vector, by allowing to specify how impure a function is. The changes would be reflected in source code by altering fn pure()'s signature to return some struct or bitflag. Specifying if the function alters the underlying event, relies on the underlying event's data or depends on external factors (such as system time) can prove to be useful.