Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: common/tsmon/monitor/acq_test.go

Issue 2123853002: Added unit annotation supports onto tsmon in go. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Specify the unit of logdog/collector/subscription/processing_time_ms with types.Milliseconds Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/tsmon/monitor/acq.go ('k') | common/tsmon/runtimestats/runtimestats.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package monitor 5 package monitor
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "math" 9 "math"
10 "testing" 10 "testing"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 func TestSerializeCell(t *testing.T) { 131 func TestSerializeCell(t *testing.T) {
132 Convey("Int", t, func() { 132 Convey("Int", t, func() {
133 ret := SerializeCell(types.Cell{ 133 ret := SerializeCell(types.Cell{
134 types.MetricInfo{ 134 types.MetricInfo{
135 Name: "foo", 135 Name: "foo",
136 Description: "bar", 136 Description: "bar",
137 Fields: []field.Field{}, 137 Fields: []field.Field{},
138 ValueType: types.NonCumulativeIntType, 138 ValueType: types.NonCumulativeIntType,
139 }, 139 },
140 types.MetricMetadata{},
140 types.CellData{ 141 types.CellData{
141 FieldVals: []interface{}{}, 142 FieldVals: []interface{}{},
142 Target: &target.Task{}, 143 Target: &target.Task{},
143 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 144 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
144 Value: int64(42), 145 Value: int64(42),
145 }, 146 },
146 }) 147 })
147 So(ret, ShouldResemble, &pb.MetricsData{ 148 So(ret, ShouldResemble, &pb.MetricsData{
148 Name: proto.String("foo"), 149 Name: proto.String("foo"),
149 Description: proto.String("bar"), 150 Description: proto.String("bar"),
150 MetricNamePrefix: proto.String("/chrome/infra/"), 151 MetricNamePrefix: proto.String("/chrome/infra/"),
151 Fields: []*pb.MetricsField{}, 152 Fields: []*pb.MetricsField{},
152 Task: &pb.Task{}, 153 Task: &pb.Task{},
153 Gauge: proto.Int64(42), 154 Gauge: proto.Int64(42),
154 }) 155 })
155 }) 156 })
156 157
157 Convey("Counter", t, func() { 158 Convey("Counter", t, func() {
158 ret := SerializeCell(types.Cell{ 159 ret := SerializeCell(types.Cell{
159 types.MetricInfo{ 160 types.MetricInfo{
160 Name: "foo", 161 Name: "foo",
161 Description: "bar", 162 Description: "bar",
162 Fields: []field.Field{}, 163 Fields: []field.Field{},
163 ValueType: types.CumulativeIntType, 164 ValueType: types.CumulativeIntType,
164 }, 165 },
166 types.MetricMetadata{},
165 types.CellData{ 167 types.CellData{
166 FieldVals: []interface{}{}, 168 FieldVals: []interface{}{},
167 Target: &target.Task{}, 169 Target: &target.Task{},
168 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 170 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
169 Value: int64(42), 171 Value: int64(42),
170 }, 172 },
171 }) 173 })
172 So(ret, ShouldResemble, &pb.MetricsData{ 174 So(ret, ShouldResemble, &pb.MetricsData{
173 Name: proto.String("foo"), 175 Name: proto.String("foo"),
174 Description: proto.String("bar"), 176 Description: proto.String("bar"),
175 MetricNamePrefix: proto.String("/chrome/infra/"), 177 MetricNamePrefix: proto.String("/chrome/infra/"),
176 Fields: []*pb.MetricsField{}, 178 Fields: []*pb.MetricsField{},
177 StartTimestampUs: proto.Uint64(946782245000000), 179 StartTimestampUs: proto.Uint64(946782245000000),
178 Task: &pb.Task{}, 180 Task: &pb.Task{},
179 Counter: proto.Int64(42), 181 Counter: proto.Int64(42),
180 }) 182 })
181 }) 183 })
182 184
183 Convey("Float", t, func() { 185 Convey("Float", t, func() {
184 ret := SerializeCell(types.Cell{ 186 ret := SerializeCell(types.Cell{
185 types.MetricInfo{ 187 types.MetricInfo{
186 Name: "foo", 188 Name: "foo",
187 Description: "bar", 189 Description: "bar",
188 Fields: []field.Field{}, 190 Fields: []field.Field{},
189 ValueType: types.NonCumulativeFloatType, 191 ValueType: types.NonCumulativeFloatType,
190 }, 192 },
193 types.MetricMetadata{},
191 types.CellData{ 194 types.CellData{
192 FieldVals: []interface{}{}, 195 FieldVals: []interface{}{},
193 Target: &target.Task{}, 196 Target: &target.Task{},
194 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 197 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
195 Value: float64(42), 198 Value: float64(42),
196 }, 199 },
197 }) 200 })
198 So(ret, ShouldResemble, &pb.MetricsData{ 201 So(ret, ShouldResemble, &pb.MetricsData{
199 Name: proto.String("foo"), 202 Name: proto.String("foo"),
200 Description: proto.String("bar"), 203 Description: proto.String("bar"),
201 MetricNamePrefix: proto.String("/chrome/infra/"), 204 MetricNamePrefix: proto.String("/chrome/infra/"),
202 Fields: []*pb.MetricsField{}, 205 Fields: []*pb.MetricsField{},
203 Task: &pb.Task{}, 206 Task: &pb.Task{},
204 NoncumulativeDoubleValue: proto.Float64(42), 207 NoncumulativeDoubleValue: proto.Float64(42),
205 }) 208 })
206 }) 209 })
207 210
208 Convey("FloatCounter", t, func() { 211 Convey("FloatCounter", t, func() {
209 ret := SerializeCell(types.Cell{ 212 ret := SerializeCell(types.Cell{
210 types.MetricInfo{ 213 types.MetricInfo{
211 Name: "foo", 214 Name: "foo",
212 Description: "bar", 215 Description: "bar",
213 Fields: []field.Field{}, 216 Fields: []field.Field{},
214 ValueType: types.CumulativeFloatType, 217 ValueType: types.CumulativeFloatType,
215 }, 218 },
219 types.MetricMetadata{},
216 types.CellData{ 220 types.CellData{
217 FieldVals: []interface{}{}, 221 FieldVals: []interface{}{},
218 Target: &target.Task{}, 222 Target: &target.Task{},
219 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 223 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
220 Value: float64(42), 224 Value: float64(42),
221 }, 225 },
222 }) 226 })
223 So(ret, ShouldResemble, &pb.MetricsData{ 227 So(ret, ShouldResemble, &pb.MetricsData{
224 Name: proto.String("foo"), 228 Name: proto.String("foo"),
225 Description: proto.String("bar"), 229 Description: proto.String("bar"),
226 MetricNamePrefix: proto.String("/chrome/infra/"), 230 MetricNamePrefix: proto.String("/chrome/infra/"),
227 Fields: []*pb.MetricsField{}, 231 Fields: []*pb.MetricsField{},
228 StartTimestampUs: proto.Uint64(946782245000000), 232 StartTimestampUs: proto.Uint64(946782245000000),
229 Task: &pb.Task{}, 233 Task: &pb.Task{},
230 CumulativeDoubleValue: proto.Float64(42), 234 CumulativeDoubleValue: proto.Float64(42),
231 }) 235 })
232 }) 236 })
233 237
234 Convey("String", t, func() { 238 Convey("String", t, func() {
235 ret := SerializeCell(types.Cell{ 239 ret := SerializeCell(types.Cell{
236 types.MetricInfo{ 240 types.MetricInfo{
237 Name: "foo", 241 Name: "foo",
238 Description: "bar", 242 Description: "bar",
239 Fields: []field.Field{}, 243 Fields: []field.Field{},
240 ValueType: types.StringType, 244 ValueType: types.StringType,
241 }, 245 },
246 types.MetricMetadata{},
242 types.CellData{ 247 types.CellData{
243 FieldVals: []interface{}{}, 248 FieldVals: []interface{}{},
244 Target: &target.Task{}, 249 Target: &target.Task{},
245 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 250 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
246 Value: "hello", 251 Value: "hello",
247 }, 252 },
248 }) 253 })
249 So(ret, ShouldResemble, &pb.MetricsData{ 254 So(ret, ShouldResemble, &pb.MetricsData{
250 Name: proto.String("foo"), 255 Name: proto.String("foo"),
251 Description: proto.String("bar"), 256 Description: proto.String("bar"),
252 MetricNamePrefix: proto.String("/chrome/infra/"), 257 MetricNamePrefix: proto.String("/chrome/infra/"),
253 Fields: []*pb.MetricsField{}, 258 Fields: []*pb.MetricsField{},
254 Task: &pb.Task{}, 259 Task: &pb.Task{},
255 StringValue: proto.String("hello"), 260 StringValue: proto.String("hello"),
256 }) 261 })
257 }) 262 })
258 263
259 Convey("Boolean", t, func() { 264 Convey("Boolean", t, func() {
260 ret := SerializeCell(types.Cell{ 265 ret := SerializeCell(types.Cell{
261 types.MetricInfo{ 266 types.MetricInfo{
262 Name: "foo", 267 Name: "foo",
263 Description: "bar", 268 Description: "bar",
264 Fields: []field.Field{}, 269 Fields: []field.Field{},
265 ValueType: types.BoolType, 270 ValueType: types.BoolType,
266 }, 271 },
272 types.MetricMetadata{},
267 types.CellData{ 273 types.CellData{
268 FieldVals: []interface{}{}, 274 FieldVals: []interface{}{},
269 Target: &target.Task{}, 275 Target: &target.Task{},
270 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 276 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
271 Value: true, 277 Value: true,
272 }, 278 },
273 }) 279 })
274 So(ret, ShouldResemble, &pb.MetricsData{ 280 So(ret, ShouldResemble, &pb.MetricsData{
275 Name: proto.String("foo"), 281 Name: proto.String("foo"),
276 Description: proto.String("bar"), 282 Description: proto.String("bar"),
(...skipping 10 matching lines...) Expand all
287 JobName: proto.String("world"), 293 JobName: proto.String("world"),
288 } 294 }
289 295
290 ret := SerializeCell(types.Cell{ 296 ret := SerializeCell(types.Cell{
291 types.MetricInfo{ 297 types.MetricInfo{
292 Name: "foo", 298 Name: "foo",
293 Description: "bar", 299 Description: "bar",
294 Fields: []field.Field{}, 300 Fields: []field.Field{},
295 ValueType: types.NonCumulativeIntType, 301 ValueType: types.NonCumulativeIntType,
296 }, 302 },
303 types.MetricMetadata{},
297 types.CellData{ 304 types.CellData{
298 FieldVals: []interface{}{}, 305 FieldVals: []interface{}{},
299 Target: &target, 306 Target: &target,
300 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC), 307 ResetTime: time.Date(2000, 1, 2, 3, 4, 5, 6, tim e.UTC),
301 Value: int64(42), 308 Value: int64(42),
302 }, 309 },
303 }) 310 })
304 So(ret, ShouldResemble, &pb.MetricsData{ 311 So(ret, ShouldResemble, &pb.MetricsData{
305 Name: proto.String("foo"), 312 Name: proto.String("foo"),
306 Description: proto.String("bar"), 313 Description: proto.String("bar"),
307 MetricNamePrefix: proto.String("/chrome/infra/"), 314 MetricNamePrefix: proto.String("/chrome/infra/"),
308 Fields: []*pb.MetricsField{}, 315 Fields: []*pb.MetricsField{},
309 Task: &pb.Task{ 316 Task: &pb.Task{
310 ServiceName: proto.String("hello"), 317 ServiceName: proto.String("hello"),
311 JobName: proto.String("world"), 318 JobName: proto.String("world"),
312 }, 319 },
313 Gauge: proto.Int64(42), 320 Gauge: proto.Int64(42),
314 }) 321 })
315 }) 322 })
316 } 323 }
OLDNEW
« no previous file with comments | « common/tsmon/monitor/acq.go ('k') | common/tsmon/runtimestats/runtimestats.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698