forked from rai-project/dlframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spans.go
43 lines (37 loc) · 896 Bytes
/
spans.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package evaluation
import (
"strings"
model "github.com/jaegertracing/jaeger/model/json"
)
type Spans []model.Span
func (spns Spans) FilterByOperationName(op string) Spans {
res := []model.Span{}
op = strings.ToLower(op)
for _, s := range spns {
if strings.ToLower(s.OperationName) == op {
res = append(res, s)
}
}
return res
}
func (spns Spans) FilterByOperationNameAndEvalTraceLevel(op string, lvl string) Spans {
res := []model.Span{}
op = strings.ToLower(op)
for _, s := range spns {
traceLevel, err := getTagValueAsString(s, "evaluation_trace_level")
if err != nil || traceLevel == "" {
continue
}
if strings.ToLower(s.OperationName) == op && traceLevel == lvl {
res = append(res, s)
}
}
return res
}
func (spns Spans) Duration() []uint64 {
res := make([]uint64, len(spns))
for ii, s := range spns {
res[ii] = uint64(s.Duration)
}
return res
}