Skip to content

Commit 9e798ce

Browse files
committed
metrics: make LabelFromKey optional / omitempty
1 parent e660c89 commit 9e798ce

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pkg/metrics/internal/config/config_metrics_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type MetricGauge struct {
3232
// ValueFrom is the path to a numeric field under Path that will be the metric value.
3333
ValueFrom []string `yaml:"valueFrom" json:"valueFrom"`
3434
// LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key.
35-
LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"`
35+
LabelFromKey string `yaml:"labelFromKey,omitempty" json:"labelFromKey,omitempty"`
3636
// NilIsZero indicates that if a value is nil it will be treated as zero value.
3737
NilIsZero bool `yaml:"nilIsZero" json:"nilIsZero"`
3838
}
@@ -42,7 +42,7 @@ type MetricGauge struct {
4242
type MetricInfo struct {
4343
MetricMeta `yaml:",inline" json:",inline"`
4444
// LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key.
45-
LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"`
45+
LabelFromKey string `yaml:"labelFromKey,omitempty" json:"labelFromKey,omitempty"`
4646
}
4747

4848
// MetricStateSet is a metric which represent a series of related boolean values, also called a bitset.

pkg/metrics/internal/config/doc.go

+2
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ limitations under the License.
3535
// * Rename the package to `config`.
3636
// * Add `omitempty` to:
3737
// - `MetricMeta.LabelsFromPath
38+
// - `MetricGauge.LabelFromkey`
39+
// - `MetricInfo.LabelFromkey`
3840
package config

0 commit comments

Comments
 (0)