Skip to content

Commit

Permalink
Fix the system-tag cli help default values after #1148 (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov authored Oct 29, 2019
1 parent c2d73ba commit 9e1c5c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]`")
Expand Down
13 changes: 12 additions & 1 deletion stats/system_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit 9e1c5c1

Please sign in to comment.