Merge pull request #10815 from Iceber/unmarshal-metrics-to-type
metrics: Use UnmarshalTo instead of UnmarshalAny
This commit is contained in:
commit
d1245c6faf
@ -148,16 +148,12 @@ func (c *Collector) collect(entry entry, ch chan<- prometheus.Metric, block bool
|
||||
return
|
||||
}
|
||||
|
||||
data, err := typeurl.UnmarshalAny(stats)
|
||||
if err != nil {
|
||||
s := &v1.Metrics{}
|
||||
if err := typeurl.UnmarshalTo(stats, s); err != nil {
|
||||
log.L.WithError(err).Errorf("unmarshal stats for %s", t.ID())
|
||||
return
|
||||
}
|
||||
s, ok := data.(*v1.Metrics)
|
||||
if !ok {
|
||||
log.L.WithError(err).Errorf("invalid metric type for %s", t.ID())
|
||||
return
|
||||
}
|
||||
|
||||
ns := entry.ns
|
||||
if ns == nil {
|
||||
ns = c.ns
|
||||
|
@ -141,16 +141,11 @@ func (c *Collector) collect(entry entry, ch chan<- prometheus.Metric, block bool
|
||||
return
|
||||
}
|
||||
|
||||
data, err := typeurl.UnmarshalAny(stats)
|
||||
if err != nil {
|
||||
s := &v2.Metrics{}
|
||||
if err := typeurl.UnmarshalTo(stats, s); err != nil {
|
||||
log.L.WithError(err).Errorf("unmarshal stats for %s", t.ID())
|
||||
return
|
||||
}
|
||||
s, ok := data.(*v2.Metrics)
|
||||
if !ok {
|
||||
log.L.WithError(err).Errorf("invalid metric type for %s", t.ID())
|
||||
return
|
||||
}
|
||||
ns := entry.ns
|
||||
if ns == nil {
|
||||
ns = c.ns
|
||||
|
Loading…
Reference in New Issue
Block a user