-
Notifications
You must be signed in to change notification settings - Fork 117
/
observability_utils.go
112 lines (96 loc) · 2.22 KB
/
observability_utils.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package server
import (
runtimev1 "github.com/rilldata/rill/proto/gen/rill/runtime/v1"
"google.golang.org/protobuf/types/known/timestamppb"
)
func safeTimeStr(t *timestamppb.Timestamp) string {
if t == nil {
return ""
}
return t.AsTime().String()
}
func filterCount(m *runtimev1.Expression) int {
if m == nil {
return 0
}
c := 0
switch e := m.Expression.(type) {
case *runtimev1.Expression_Ident:
c++
case *runtimev1.Expression_Cond:
for _, expr := range e.Cond.Exprs {
c += filterCount(expr)
}
}
return c
}
func marshalInlineMeasure(ms []*runtimev1.InlineMeasure) []string {
if len(ms) == 0 {
return make([]string, 0)
}
names := make([]string, len(ms))
for i := 0; i < len(ms); i++ {
names[i] = ms[i].Name
}
return nil
}
func marshalMetricsViewAggregationDimension(ms []*runtimev1.MetricsViewAggregationDimension) []string {
if len(ms) == 0 {
return make([]string, 0)
}
names := make([]string, len(ms))
for i := 0; i < len(ms); i++ {
names[i] = ms[i].Name
}
return nil
}
func marshalMetricsViewAggregationMeasures(ms []*runtimev1.MetricsViewAggregationMeasure) []string {
if len(ms) == 0 {
return make([]string, 0)
}
names := make([]string, len(ms))
for i := 0; i < len(ms); i++ {
names[i] = ms[i].Name
}
return nil
}
func marshalMetricsViewAggregationSort(ms []*runtimev1.MetricsViewAggregationSort) []string {
if len(ms) == 0 {
return make([]string, 0)
}
names := make([]string, len(ms))
for i := 0; i < len(ms); i++ {
names[i] = ms[i].Name
}
return nil
}
func marshalMetricsViewComparisonSort(ms []*runtimev1.MetricsViewComparisonSort) []string {
if len(ms) == 0 {
return make([]string, 0)
}
names := make([]string, len(ms))
for i := 0; i < len(ms); i++ {
names[i] = ms[i].Name
}
return nil
}
func marshalMetricsViewSort(ms []*runtimev1.MetricsViewSort) []string {
if len(ms) == 0 {
return make([]string, 0)
}
names := make([]string, len(ms))
for i := 0; i < len(ms); i++ {
names[i] = ms[i].Name
}
return nil
}
func marshalColumnTimeSeriesRequestBasicMeasure(m []*runtimev1.ColumnTimeSeriesRequest_BasicMeasure) []string {
if len(m) == 0 {
return make([]string, 0)
}
ids := make([]string, len(m))
for i := 0; i < len(m); i++ {
ids[i] = m[i].Id
}
return ids
}