mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 22:55:56 +08:00
chore(query-service): update GoValuateFuncs
definitions (#5106)
* fix: parse both unix int and RFC3339 string in toUnixTimestamp * chore: return GoValuateFuncs as float64 * chore: remove toUnixTimestamp function --------- Signed-off-by: Prashant Shahi <prashant@signoz.io>
This commit is contained in:
parent
67779d6c2c
commit
0f9c8d91ef
@ -266,20 +266,9 @@ func EvalFuncs() map[string]govaluate.ExpressionFunction {
|
||||
GoValuateFuncs["radians"] = func(args ...interface{}) (interface{}, error) {
|
||||
return args[0].(float64) * math.Pi / 180, nil
|
||||
}
|
||||
|
||||
// Returns the current Unix timestamp in seconds.
|
||||
GoValuateFuncs["now"] = func(args ...interface{}) (interface{}, error) {
|
||||
return time.Now().Unix(), nil
|
||||
}
|
||||
|
||||
GoValuateFuncs["toUnixTimestamp"] = func(args ...interface{}) (interface{}, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf("toUnixTimestamp requires exactly one argument")
|
||||
}
|
||||
t, err := time.Parse(time.RFC3339, args[0].(string))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t.Unix(), nil
|
||||
return float64(time.Now().Unix()), nil
|
||||
}
|
||||
|
||||
return GoValuateFuncs
|
||||
|
Loading…
x
Reference in New Issue
Block a user