options.go
func Tags(tags ...string) Option {
	if len(tags)%2 != 0 {
		panic("statsd: Tags only accepts an even number of arguments")
	}

	return Option(func(c *config) {
		if len(tags) == 0 {
			return
		}

		newTags := make([]tag, len(tags)/2)
		for i := 0; i < len(tags)/2; i++ {
			newTags[i] = tag{K: tags[2*i], V: tags[2*i+1]}
		}

		for _, newTag := range newTags {
			exists := false
			for _, oldTag := range c.Client.Tags {
				if newTag.K == oldTag.K {
					exists = true
					oldTag.V = newTag.V
				}
			}
			if !exists {
				c.Client.Tags = append(c.Client.Tags, tag{
					K: newTag.K,
					V: newTag.V,
				})
			}
		}
	})
}
func Tags(tags ...string) Option {
	if len(tags)%2 != 0 {
		panic("statsd: Tags only accepts an even number of arguments")
	}

	return Option(func(c *config) {
		if len(tags) == 0 {
			return
		}

		newTags := make([]tag, len(tags)/2)
		for i := 0; i < len(tags)/2; i++ {
			newTags[i] = tag{K: tags[2*i], V: tags[2*i+1]}
		}

		for _, newTag := range newTags {
			exists := false
			for _, oldTag := range c.Client.Tags {
				if newTag.K == oldTag.K {
					exists = true
					oldTag.V = newTag.V
				}
			}
			if !exists {
				c.Client.Tags = append(c.Client.Tags, tag{
					K: newTag.K,
					V: newTag.V,
				})
			}
		}
	})
}
func Tags ( tags ... string ) Option { if len ( tags ) % 2 != 0 { panic ( " " ) } return Option ( func ( c * config ) { if len ( tags ) == 0 { return } newTags := make ( [ ] tag , len ( tags ) / 2 ) for i := 0 ; i < len ( tags ) / 2 ; i ++ { newTags [ i ] = tag { K : tags [ 2 * i ] , V : tags [ 2 * i + 1 ] } } for _ , newTag := range newTags { exists := false for _ , oldTag := range c . Client . Tags { if newTag . K == oldTag . K { exists = true oldTag . V = newTag . V } } if ! exists { c . Client . Tags = append ( c . Client . Tags , tag { K : newTag . K , V : newTag . V , } ) } } } ) }
// Tags appends the given tags to the tags sent with every metrics. If a tag
// already exists, it is replaced.
//
// The tags must be set as key-value pairs. If the number of tags is not even,
// Tags panics.
//
// If the format of tags have not been set using the TagsFormat option, the tags
// will be ignored.
Tags appends the given tags to the tags sent with every metrics . If a tag already exists it is replaced . The tags must be set as key - value pairs . If the number of tags is not even Tags panics . If the format of tags have not been set using the TagsFormat option the tags will be ignored .