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

Unified Diff: common/tsmon/monitor/acq.go

Issue 1857643003: Revert of Migrate tsmon protos to proto3 (Closed) Base URL: git@github.com:luci/luci-go.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/tsmon/metric/metric_test.go ('k') | common/tsmon/monitor/acq_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/tsmon/monitor/acq.go
diff --git a/common/tsmon/monitor/acq.go b/common/tsmon/monitor/acq.go
index 41c4004033c4260a33a546a54176896a6e13c4c8..1ca260568247866be53a13c9c66a926a247c3c75 100644
--- a/common/tsmon/monitor/acq.go
+++ b/common/tsmon/monitor/acq.go
@@ -8,6 +8,7 @@
"math"
"time"
+ "github.com/golang/protobuf/proto"
"github.com/luci/luci-go/common/tsmon/distribution"
"github.com/luci/luci-go/common/tsmon/field"
"github.com/luci/luci-go/common/tsmon/types"
@@ -35,11 +36,11 @@
// SerializeCell creates one MetricsData message from a cell.
func SerializeCell(c types.Cell) *pb.MetricsData {
d := pb.MetricsData{}
- d.Name = c.Name
- d.Description = c.Description
- d.MetricNamePrefix = metricNamePrefix
+ d.Name = proto.String(c.Name)
+ d.Description = proto.String(c.Description)
+ d.MetricNamePrefix = proto.String(metricNamePrefix)
d.Fields = field.Serialize(c.Fields, c.FieldVals)
- d.StartTimestampUs = uint64(c.ResetTime.UnixNano() / int64(time.Microsecond))
+ d.StartTimestampUs = proto.Uint64(uint64(c.ResetTime.UnixNano() / int64(time.Microsecond)))
c.Target.PopulateProto(&d)
SerializeValue(c.ValueType, c.Value, &d)
@@ -50,23 +51,23 @@
func SerializeValue(typ types.ValueType, value interface{}, d *pb.MetricsData) {
switch typ {
case types.NonCumulativeIntType:
- d.Gauge = value.(int64)
+ d.Gauge = proto.Int64(value.(int64))
case types.CumulativeIntType:
- d.Counter = value.(int64)
+ d.Counter = proto.Int64(value.(int64))
case types.NonCumulativeFloatType:
- d.NoncumulativeDoubleValue = value.(float64)
+ d.NoncumulativeDoubleValue = proto.Float64(value.(float64))
case types.CumulativeFloatType:
- d.CumulativeDoubleValue = value.(float64)
+ d.CumulativeDoubleValue = proto.Float64(value.(float64))
case types.StringType:
- d.StringValue = value.(string)
+ d.StringValue = proto.String(value.(string))
case types.BoolType:
- d.BooleanValue = value.(bool)
+ d.BooleanValue = proto.Bool(value.(bool))
case types.CumulativeDistributionType:
d.Distribution = serializeDistribution(value.(*distribution.Distribution))
- d.Distribution.IsCumulative = true
+ d.Distribution.IsCumulative = proto.Bool(true)
case types.NonCumulativeDistributionType:
d.Distribution = serializeDistribution(value.(*distribution.Distribution))
- d.Distribution.IsCumulative = false
+ d.Distribution.IsCumulative = proto.Bool(false)
}
}
@@ -95,19 +96,19 @@
if d.Bucketer().Width() == 0 {
switch d.Bucketer().GrowthFactor() {
case 2:
- ret.SpecType = pb.PrecomputedDistribution_CANONICAL_POWERS_OF_2
+ ret.SpecType = pb.PrecomputedDistribution_CANONICAL_POWERS_OF_2.Enum()
case math.Pow(10, 0.2):
- ret.SpecType = pb.PrecomputedDistribution_CANONICAL_POWERS_OF_10_P_0_2
+ ret.SpecType = pb.PrecomputedDistribution_CANONICAL_POWERS_OF_10_P_0_2.Enum()
case 10:
- ret.SpecType = pb.PrecomputedDistribution_CANONICAL_POWERS_OF_10
+ ret.SpecType = pb.PrecomputedDistribution_CANONICAL_POWERS_OF_10.Enum()
}
}
- if ret.SpecType == pb.PrecomputedDistribution_UNKNOWN {
- ret.SpecType = pb.PrecomputedDistribution_CUSTOM_PARAMETERIZED
- ret.Width = d.Bucketer().Width()
- ret.GrowthFactor = d.Bucketer().GrowthFactor()
- ret.NumBuckets = int32(d.Bucketer().NumFiniteBuckets())
+ if ret.SpecType == nil {
+ ret.SpecType = pb.PrecomputedDistribution_CUSTOM_PARAMETERIZED.Enum()
+ ret.Width = proto.Float64(d.Bucketer().Width())
+ ret.GrowthFactor = proto.Float64(d.Bucketer().GrowthFactor())
+ ret.NumBuckets = proto.Int32(int32(d.Bucketer().NumFiniteBuckets()))
}
// Copy the distribution bucket values. Exclude the overflow buckets on each
@@ -122,14 +123,14 @@
// Add overflow buckets if present.
if len(d.Buckets()) >= 1 {
- ret.Underflow = d.Buckets()[0]
+ ret.Underflow = proto.Int64(d.Buckets()[0])
}
if len(d.Buckets()) == d.Bucketer().NumBuckets() {
- ret.Overflow = d.Buckets()[d.Bucketer().NumBuckets()-1]
+ ret.Overflow = proto.Int64(d.Buckets()[d.Bucketer().NumBuckets()-1])
}
if d.Count() > 0 {
- ret.Mean = d.Sum() / float64(d.Count())
+ ret.Mean = proto.Float64(d.Sum() / float64(d.Count()))
}
return &ret
« no previous file with comments | « common/tsmon/metric/metric_test.go ('k') | common/tsmon/monitor/acq_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698