Do not expose info metric for nil objects
This commit is contained in:
parent
3532203e8f
commit
25f3b8f45a
|
|
@ -269,6 +269,9 @@ func (c *compiledInfo) Values(v interface{}) (result []eachValue, errs []error)
|
|||
}
|
||||
|
||||
func (c *compiledInfo) values(v interface{}) (result []eachValue, err []error) {
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
value := eachValue{Value: 1, Labels: map[string]string{}}
|
||||
addPathLabels(v, c.labelFromPath, value.Labels)
|
||||
result = append(result, value)
|
||||
|
|
|
|||
|
|
@ -209,6 +209,11 @@ func Test_values(t *testing.T) {
|
|||
}, wantResult: []eachValue{
|
||||
newEachValue(t, 1, "version", "v0.0.0"),
|
||||
}},
|
||||
{name: "info nil path", each: &compiledInfo{
|
||||
compiledCommon{
|
||||
path: mustCompilePath(t, "does", "not", "exist"),
|
||||
},
|
||||
}, wantResult: nil},
|
||||
{name: "stateset", each: &compiledStateSet{
|
||||
compiledCommon: compiledCommon{
|
||||
path: mustCompilePath(t, "status", "phase"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue