func (v *value) updateJsonOrRpcMetric( s *session, metric *messages.Metric, encoding rpcEncoding) { t := v.Type() metric.Kind = t metric.Bits = v.Bits() switch t { case types.Dist: snapshot := v.AsDistribution().Snapshot() metric.Value = &messages.Distribution{ Min: snapshot.Min, Max: snapshot.Max, Average: snapshot.Average, Median: snapshot.Median, Sum: snapshot.Sum, Count: snapshot.Count, Generation: snapshot.Generation, IsNotCumulative: snapshot.IsNotCumulative, Ranges: asRanges(snapshot.Breakdown)} default: metric.Value = v.AsInterface(s) } if encoding == jsonEncoding { metric.ConvertToJson() } }
func (v *value) updateJsonOrRpcMetric( s *session, metric *messages.Metric, encoding rpcEncoding) { t := v.Type() metric.Kind = t metric.SubType = v.SubType() metric.Bits = v.Bits() metric.Unit = v.Unit() switch t { case types.Dist: dist := v.AsDistribution() snapshot := dist.Snapshot() metric.Value = &messages.Distribution{ Min: snapshot.Min, Max: snapshot.Max, Average: snapshot.Average, Median: snapshot.Median, Sum: snapshot.Sum, Count: snapshot.Count, Generation: snapshot.Generation, IsNotCumulative: snapshot.IsNotCumulative, Ranges: asRanges(snapshot.Breakdown)} metric.GroupId = dist.GroupId() metric.TimeStamp = snapshot.TimeStamp case types.List: alist := v.AsList() metric.Value, metric.TimeStamp = alist.AsSlice() metric.GroupId = alist.GroupId() default: if s == nil { s = newSession() defer s.Close() } metric.Value = v.AsInterface(s) metric.GroupId = v.RegionId() metric.TimeStamp = v.TimeStamp(s) } if encoding == jsonEncoding { metric.ConvertToJson() } }