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

Side by Side Diff: common/tsmon/monitor/acq.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/metric/standard_metrics.go ('k') | common/tsmon/monitor/acq_test.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 "math" 8 "math"
9 "time" 9 "time"
10 10
(...skipping 26 matching lines...) Expand all
37 func SerializeCell(c types.Cell) *pb.MetricsData { 37 func SerializeCell(c types.Cell) *pb.MetricsData {
38 d := pb.MetricsData{} 38 d := pb.MetricsData{}
39 d.Name = proto.String(c.Name) 39 d.Name = proto.String(c.Name)
40 d.Description = proto.String(c.Description) 40 d.Description = proto.String(c.Description)
41 d.MetricNamePrefix = proto.String(metricNamePrefix) 41 d.MetricNamePrefix = proto.String(metricNamePrefix)
42 d.Fields = field.Serialize(c.Fields, c.FieldVals) 42 d.Fields = field.Serialize(c.Fields, c.FieldVals)
43 if c.ValueType.IsCumulative() { 43 if c.ValueType.IsCumulative() {
44 d.StartTimestampUs = proto.Uint64(uint64(c.ResetTime.UnixNano() / int64(time.Microsecond))) 44 d.StartTimestampUs = proto.Uint64(uint64(c.ResetTime.UnixNano() / int64(time.Microsecond)))
45 } 45 }
46 c.Target.PopulateProto(&d) 46 c.Target.PopulateProto(&d)
47 if c.Units.IsSpecified() {
48 d.Units = c.Units.AsProto()
49 }
47 50
48 SerializeValue(c.ValueType, c.Value, &d) 51 SerializeValue(c.ValueType, c.Value, &d)
49 return &d 52 return &d
50 } 53 }
51 54
52 // SerializeValue writes one metric's value into the MetricsData message. 55 // SerializeValue writes one metric's value into the MetricsData message.
53 func SerializeValue(typ types.ValueType, value interface{}, d *pb.MetricsData) { 56 func SerializeValue(typ types.ValueType, value interface{}, d *pb.MetricsData) {
54 switch typ { 57 switch typ {
55 case types.NonCumulativeIntType: 58 case types.NonCumulativeIntType:
56 d.Gauge = proto.Int64(value.(int64)) 59 d.Gauge = proto.Int64(value.(int64))
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if len(d.Buckets()) == d.Bucketer().NumBuckets() { 133 if len(d.Buckets()) == d.Bucketer().NumBuckets() {
131 ret.Overflow = proto.Int64(d.Buckets()[d.Bucketer().NumBuckets() -1]) 134 ret.Overflow = proto.Int64(d.Buckets()[d.Bucketer().NumBuckets() -1])
132 } 135 }
133 136
134 if d.Count() > 0 { 137 if d.Count() > 0 {
135 ret.Mean = proto.Float64(d.Sum() / float64(d.Count())) 138 ret.Mean = proto.Float64(d.Sum() / float64(d.Count()))
136 } 139 }
137 140
138 return &ret 141 return &ret
139 } 142 }
OLDNEW
« no previous file with comments | « common/tsmon/metric/standard_metrics.go ('k') | common/tsmon/monitor/acq_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698