This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
/
node.go
213 lines (173 loc) · 5.17 KB
/
node.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package models
import (
"fmt"
"github.com/grafana/metrictank/cluster"
"github.com/grafana/metrictank/schema"
opentracing "github.com/opentracing/opentracing-go"
traceLog "github.com/opentracing/opentracing-go/log"
)
type NodeStatus struct {
Primary string `json:"primary" form:"primary" binding:"Required"`
}
type ClusterStatus struct {
ClusterName string `json:"clusterName"`
NodeName string `json:"nodeName"`
Members []cluster.Node `json:"members"`
}
type ClusterMembers struct {
Members []string `json:"members"`
}
type ClusterMembersResp struct {
Status string `json:"status"`
MembersAdded int `json:"membersAdded"`
}
type IndexList struct {
OrgId uint32 `json:"orgId" form:"orgId" binding:"Required"`
}
func (i IndexList) Trace(span opentracing.Span) {
span.SetTag("orgId", i.OrgId)
}
func (i IndexList) TraceDebug(span opentracing.Span) {
}
type IndexFindByTag struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Expr []string `json:"expressions"`
From int64 `json:"from"`
}
func (t IndexFindByTag) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(
traceLog.Int64("from", t.From),
traceLog.String("expressions", fmt.Sprintf("%q", t.Expr)),
)
}
func (i IndexFindByTag) TraceDebug(span opentracing.Span) {
}
type IndexTagDetails struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Filter string `json:"filter"`
Tag string `json:"tag" binding:"Required"`
}
func (t IndexTagDetails) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(
traceLog.String("filter", t.Filter),
traceLog.String("tag", t.Tag),
)
}
func (i IndexTagDetails) TraceDebug(span opentracing.Span) {
}
type IndexTags struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Filter string `json:"filter"`
}
func (t IndexTags) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(
traceLog.String("filter", t.Filter),
)
}
func (i IndexTags) TraceDebug(span opentracing.Span) {
}
type IndexAutoCompleteTags struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Prefix string `json:"Prefix"`
Expr []string `json:"expressions"`
Limit uint `json:"limit"`
}
func (t IndexAutoCompleteTags) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(
traceLog.String("prefix", t.Prefix),
traceLog.String("expressions", fmt.Sprintf("%q", t.Expr)),
traceLog.Int("limit", int(t.Limit)),
)
}
func (i IndexAutoCompleteTags) TraceDebug(span opentracing.Span) {
}
type IndexAutoCompleteTagValues struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Tag string `json:"tag"`
Prefix string `json:"prefix"`
Expr []string `json:"expressions"`
Limit uint `json:"limit"`
}
func (t IndexAutoCompleteTagValues) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(
traceLog.String("prefix", t.Prefix),
traceLog.String("tag", t.Tag),
traceLog.String("expressions", fmt.Sprintf("%q", t.Expr)),
traceLog.Int("limit", int(t.Limit)),
)
}
func (i IndexAutoCompleteTagValues) TraceDebug(span opentracing.Span) {
}
type IndexTagTerms struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Tags []string `json:"tags"`
Expr []string `json:"expressions"`
}
func (t IndexTagTerms) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(
traceLog.String("tags", fmt.Sprintf("%q", t.Expr)),
traceLog.String("expressions", fmt.Sprintf("%q", t.Expr)),
)
}
func (i IndexTagTerms) TraceDebug(span opentracing.Span) {
}
type IndexTagDelSeries struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Paths []string `json:"path" form:"path"`
}
func (t IndexTagDelSeries) Trace(span opentracing.Span) {
span.SetTag("orgId", t.OrgId)
span.LogFields(traceLog.String("paths", fmt.Sprintf("%q", t.Paths)))
}
func (i IndexTagDelSeries) TraceDebug(span opentracing.Span) {
}
type IndexGet struct {
MKey schema.MKey `json:"id" form:"id" binding:"Required"`
}
type IndexFind struct {
Patterns []string `json:"patterns" form:"patterns" binding:"Required"`
OrgId uint32 `json:"orgId" form:"orgId" binding:"Required"`
From int64 `json:"from" form:"from"`
}
func (i IndexFind) Trace(span opentracing.Span) {
span.SetTag("orgId", i.OrgId)
span.LogFields(
traceLog.Int64("from", i.From),
traceLog.String("q", fmt.Sprintf("%q", i.Patterns)),
)
}
func (i IndexFind) TraceDebug(span opentracing.Span) {
}
type GetData struct {
Requests []Req `json:"requests" binding:"Required"`
}
func (g GetData) Trace(span opentracing.Span) {
span.LogFields(traceLog.Int("num_reqs", len(g.Requests)))
}
func (g GetData) TraceDebug(span opentracing.Span) {
// max span size is 64kB. anything higher will be discarded
tolog := g.Requests
if len(g.Requests) > 45 {
span.SetTag("udp_cutoff", true)
tolog = g.Requests[:45]
}
for _, r := range tolog {
r.TraceLog(span)
}
}
type IndexDelete struct {
Query string `json:"query" form:"query" binding:"Required"`
OrgId uint32 `json:"orgId" form:"orgId" binding:"Required"`
}
func (i IndexDelete) Trace(span opentracing.Span) {
span.SetTag("orgId", i.OrgId)
span.LogFields(traceLog.String("q", i.Query))
}
func (i IndexDelete) TraceDebug(span opentracing.Span) {
}