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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := typeurl.UnmarshalAny(stats)
|
s := &v1.Metrics{}
|
||||||
if err != nil {
|
if err := typeurl.UnmarshalTo(stats, s); err != nil {
|
||||||
log.L.WithError(err).Errorf("unmarshal stats for %s", t.ID())
|
log.L.WithError(err).Errorf("unmarshal stats for %s", t.ID())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s, ok := data.(*v1.Metrics)
|
|
||||||
if !ok {
|
|
||||||
log.L.WithError(err).Errorf("invalid metric type for %s", t.ID())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ns := entry.ns
|
ns := entry.ns
|
||||||
if ns == nil {
|
if ns == nil {
|
||||||
ns = c.ns
|
ns = c.ns
|
||||||
|
@ -141,16 +141,11 @@ func (c *Collector) collect(entry entry, ch chan<- prometheus.Metric, block bool
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := typeurl.UnmarshalAny(stats)
|
s := &v2.Metrics{}
|
||||||
if err != nil {
|
if err := typeurl.UnmarshalTo(stats, s); err != nil {
|
||||||
log.L.WithError(err).Errorf("unmarshal stats for %s", t.ID())
|
log.L.WithError(err).Errorf("unmarshal stats for %s", t.ID())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s, ok := data.(*v2.Metrics)
|
|
||||||
if !ok {
|
|
||||||
log.L.WithError(err).Errorf("invalid metric type for %s", t.ID())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ns := entry.ns
|
ns := entry.ns
|
||||||
if ns == nil {
|
if ns == nil {
|
||||||
ns = c.ns
|
ns = c.ns
|
||||||
|
Loading…
Reference in New Issue
Block a user