labelset

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package labelset implements parsing/normalizing of string representation of the Label Set of a profile.

This is used by the /ingest endpoint, as described in the original Pyroscope API. We keep this mainly for backwards compatability.

Index

Constants

View Source
const ProfileIDLabelName = "profile_id"
View Source
const ReservedLabelNameName = "__name__"

Variables

View Source
var (
	ErrInvalidServiceName    = errors.New("invalid service name")
	ErrInvalidLabelSet       = errors.New("invalid label set")
	ErrInvalidLabelName      = errors.New("invalid label name")
	ErrServiceNameIsRequired = errors.New("service name is required")
	ErrLabelNameIsRequired   = errors.New("label name is required")
	ErrLabelNameReserved     = errors.New("label name is reserved")
)

Functions

func FromTreeToDictLabelSet

func FromTreeToDictLabelSet(k string) string

FromTreeToDictLabelSet returns app name from tree key k: given tree key "foo{}:0:1234567890", the call returns "foo".

Before tags support, segment key form (i.e. app name + tags: foo{key=value}) has been used to reference a dictionary (trie).

func IsLabelNameReserved

func IsLabelNameReserved(k string) bool

func IsLabelNameRuneAllowed

func IsLabelNameRuneAllowed(r rune) bool

func IsServiceNameRuneAllowed

func IsServiceNameRuneAllowed(r rune) bool

func ParseTreeLabelSet

func ParseTreeLabelSet(k string) (time.Time, int, error)

ParseTreeLabelSet retrieves tree time and depth level from the given key.

func ServiceNameLabelSet

func ServiceNameLabelSet(appName string) string

func TreeLabelSet

func TreeLabelSet(k string, depth int, unixTime int64) string

func ValidateLabelName

func ValidateLabelName(k string) error

ValidateLabelName report an error if the given key k violates constraints.

The function should be used to validate user input. The function returns ErrLabelNameReserved if the key is valid but reserved for internal use.

func ValidateLabelSet

func ValidateLabelSet(k *LabelSet) error

func ValidateServiceName

func ValidateServiceName(n string) error

ValidateServiceName report an error if the given app name n violates constraints.

Types

type Error

type Error struct {
	Inner error
	Expr  string
}

func NewInvalidServiceNameRuneError

func NewInvalidServiceNameRuneError(k string, r rune) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type LabelSet

type LabelSet struct {
	// contains filtered or unexported fields
}

func New

func New(labels map[string]string) *LabelSet

func Parse

func Parse(name string) (*LabelSet, error)

func (*LabelSet) Add

func (k *LabelSet) Add(key, value string)

func (*LabelSet) Clone

func (k *LabelSet) Clone() *LabelSet

func (*LabelSet) DictLabelSet

func (k *LabelSet) DictLabelSet() string

func (*LabelSet) HasProfileID

func (k *LabelSet) HasProfileID() bool

func (*LabelSet) LabelSet

func (k *LabelSet) LabelSet() string

func (*LabelSet) Labels

func (k *LabelSet) Labels() map[string]string

func (*LabelSet) Normalized

func (l *LabelSet) Normalized() string

func (*LabelSet) ProfileID

func (k *LabelSet) ProfileID() (string, bool)

func (*LabelSet) ServiceName

func (k *LabelSet) ServiceName() string

func (*LabelSet) TreeLabelSet

func (k *LabelSet) TreeLabelSet(depth int, t time.Time) string

type ParserState

type ParserState int

Jump to

Keyboard shortcuts

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