Skip to content

Commit 3f3efc6

Browse files
enhance: Add 2 time helpers for average and median (#3748)
* enhance: Add averagetime function which allows to compute averagetime span * enhance: lint * enhance: Add median function and act on @mmetc feedback * enhance: NIT on tests * enhance: switch to []time.Time instead and handle using expr map which returns interfaces * enhance: Add a bunch of test cases * enhance: Rename *duration to *interval
1 parent aff3649 commit 3f3efc6

File tree

3 files changed

+532
-0
lines changed

3 files changed

+532
-0
lines changed

pkg/exprhelpers/expr_lib.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,22 @@ var exprFuncs = []exprCustomFunc{
517517
new(func(*http.Request) string),
518518
},
519519
},
520+
{
521+
name: "AverageInterval",
522+
function: AverageInterval,
523+
signature: []any{
524+
new(func([]time.Time) time.Duration),
525+
new(func([]interface{}) time.Duration),
526+
},
527+
},
528+
{
529+
name: "MedianInterval",
530+
function: MedianInterval,
531+
signature: []any{
532+
new(func([]time.Time) time.Duration),
533+
new(func([]interface{}) time.Duration),
534+
},
535+
},
520536
}
521537

522538
//go 1.20 "CutPrefix": strings.CutPrefix,

0 commit comments

Comments
 (0)