Skip to content

Commit

Permalink
metrics: make LabelFromKey optional / omitempty
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Aug 28, 2024
1 parent e660c89 commit 9e798ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/metrics/internal/config/config_metrics_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MetricGauge struct {
// ValueFrom is the path to a numeric field under Path that will be the metric value.
ValueFrom []string `yaml:"valueFrom" json:"valueFrom"`
// LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key.
LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"`
LabelFromKey string `yaml:"labelFromKey,omitempty" json:"labelFromKey,omitempty"`
// NilIsZero indicates that if a value is nil it will be treated as zero value.
NilIsZero bool `yaml:"nilIsZero" json:"nilIsZero"`
}
Expand All @@ -42,7 +42,7 @@ type MetricGauge struct {
type MetricInfo struct {
MetricMeta `yaml:",inline" json:",inline"`
// LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key.
LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"`
LabelFromKey string `yaml:"labelFromKey,omitempty" json:"labelFromKey,omitempty"`
}

// MetricStateSet is a metric which represent a series of related boolean values, also called a bitset.
Expand Down
2 changes: 2 additions & 0 deletions pkg/metrics/internal/config/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ limitations under the License.
// * Rename the package to `config`.
// * Add `omitempty` to:
// - `MetricMeta.LabelsFromPath
// - `MetricGauge.LabelFromkey`
// - `MetricInfo.LabelFromkey`
package config

0 comments on commit 9e798ce

Please sign in to comment.