tags

package
v0.4.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTags

func ParseTags(stat string) (string, map[string]string)

ParseTags parses the statsd stat name and tags (if any) from stat.

func ReplaceChars

func ReplaceChars(s string) string

ReplaceChars replaces any invalid chars ([.:|]) in value s with '_'.

func SerializeTags

func SerializeTags(name string, tags map[string]string) string

SerializeTags serializes name and tags into a statsd stat.

Types

type Tag

type Tag struct {
	Key   string
	Value string
}

A Tag is a Key/Value statsd tag.

func NewTag

func NewTag(key, value string) Tag

NewTag returns a new Tag with any invalid chars in the value replaced.

type TagSet

type TagSet []Tag

A TagSet is a collection of Tags. All methods apart from Sort() require the TagSet to be sorted. Tags with empty keys or values should never be inserted into the TagSet since most methods rely on all the tags being valid.

func NewTagSet

func NewTagSet(tags map[string]string) TagSet

NewTagSet returns a new TagSet from the tags map.

func ParseTagSet

func ParseTagSet(stat string) (string, TagSet)

ParseTagSet parses the statsd stat name and tags (if any) from stat. It is like ParseTags, but returns a TagSet instead of a map[string]string.

func (TagSet) Contains

func (t TagSet) Contains(key string) bool

Contains returns if the TagSet contains key.

func (TagSet) Insert

func (t TagSet) Insert(p Tag) TagSet

Insert inserts Tag p into TagSet t, returning a copy unless Tag p already existed.

func (TagSet) Len

func (t TagSet) Len() int

func (TagSet) Less

func (t TagSet) Less(i, j int) bool

func (TagSet) MergePerInstanceTags

func (t TagSet) MergePerInstanceTags(tags map[string]string) TagSet

MergePerInstanceTags returns a TagSet that is the union of subScope's tags and the provided tags map with. If any keys overlap the values from the provided map are used.

The returned TagSet will have a per-instance key ("_f") and if neither the subScope or tags have this key it's value will be the default per-instance value ("i").

The method does not optimize for the case where there is only one tag because it is used less frequently.

func (TagSet) MergeTags

func (t TagSet) MergeTags(tags map[string]string) TagSet

MergeTags returns a TagSet that is the union of subScope's tags and the provided tags map. If any keys overlap the values from the provided map are used.

func (TagSet) Search

func (t TagSet) Search(key string) int

Search is the same as sort.Search() but is optimized for our use case.

func (TagSet) Serialize

func (t TagSet) Serialize(name string) string

Serialize serializes name and tags into a statsd stat. Note: the TagSet t must be sorted and have clean tag keys and values.

func (TagSet) Sort

func (t TagSet) Sort()

Sort sorts the TagSet in place and is optimized for small (N <= 8) TagSets.

func (TagSet) Swap

func (t TagSet) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL