diff --git a/cmd/options.go b/cmd/options.go index 2485f4fda28..dd88971e42f 100644 --- a/cmd/options.go +++ b/cmd/options.go @@ -68,8 +68,8 @@ func optionFlagSet() *pflag.FlagSet { // system-tags must have a default value, but we can't specify it here, otherwiese, it will always override others. // set it to nil here, and add the default in applyDefault() instead. systemTagsCliHelpText := fmt.Sprintf( - "only include these system tags in metrics (default %s)", - stats.DefaultSystemTagSet, + "only include these system tags in metrics (default %q)", + stats.DefaultSystemTagSet.SetString(), ) flags.StringSlice("system-tags", nil, systemTagsCliHelpText) flags.StringSlice("tag", nil, "add a `tag` to be applied to all samples, as `[name]=[value]`") diff --git a/stats/system_tag.go b/stats/system_tag.go index ccc08505dc2..fac1d0dda4d 100644 --- a/stats/system_tag.go +++ b/stats/system_tag.go @@ -60,7 +60,7 @@ func (i *SystemTagSet) Has(tag SystemTagSet) bool { } // Map returns the TagSet with current value from SystemTagSet -func (i *SystemTagSet) Map() TagSet { +func (i SystemTagSet) Map() TagSet { m := TagSet{} for _, tag := range SystemTagSetValues() { if i.Has(tag) { @@ -70,6 +70,17 @@ func (i *SystemTagSet) Map() TagSet { return m } +// SetString returns comma separated list of the string representation of all values in the set +func (i SystemTagSet) SetString() string { + var keys []string + for _, tag := range SystemTagSetValues() { + if i.Has(tag) { + keys = append(keys, tag.String()) + } + } + return strings.Join(keys, ",") +} + // ToSystemTagSet converts list of tags to SystemTagSet // TODO: emit error instead of discarding invalid values. func ToSystemTagSet(tags []string) *SystemTagSet {