Documentation ¶
Overview ¶
Package types defines types used by the Tagger component.
Package types defines types used by the Tagger component.
Index ¶
- Constants
- func AllPrefixesSet() map[EntityIDPrefix]struct{}
- func TagCardinalityToString(c TagCardinality) string
- type ApplyFunc
- type CollectorPriority
- type Entity
- type EntityEvent
- type EntityID
- type EntityIDPrefix
- type EventType
- type Filter
- type FilterBuilder
- type ObjectStore
- type TagCardinality
- type TagInfo
- type TaggerListEntity
- type TaggerListResponse
Constants ¶
const ( // LowCardinalityString is the string representation of the low cardinality LowCardinalityString = "low" // OrchestratorCardinalityString is the string representation of the orchestrator cardinality OrchestratorCardinalityString = "orchestrator" // ShortOrchestratorCardinalityString is the short string representation of the orchestrator cardinality ShortOrchestratorCardinalityString = "orch" // HighCardinalityString is the string representation of the high cardinality HighCardinalityString = "high" // UnknownCardinalityString represents an unknown level of cardinality UnknownCardinalityString = "unknown" )
Variables ¶
This section is empty.
Functions ¶
func AllPrefixesSet ¶
func AllPrefixesSet() map[EntityIDPrefix]struct{}
AllPrefixesSet returns a set of all possible entity id prefixes that can be used in the tagger
func TagCardinalityToString ¶
func TagCardinalityToString(c TagCardinality) string
TagCardinalityToString returns a string representation of a TagCardinality value.
Types ¶
type CollectorPriority ¶
type CollectorPriority int
CollectorPriority helps resolving dupe tags from collectors
const ( NodeRuntime CollectorPriority = iota NodeOrchestrator ClusterOrchestrator )
List of collector priorities
type Entity ¶
type Entity struct { ID EntityID HighCardinalityTags []string OrchestratorCardinalityTags []string LowCardinalityTags []string StandardTags []string }
Entity is an entity ID + tags.
func (Entity) Copy ¶
func (e Entity) Copy(cardinality TagCardinality) Entity
Copy returns a copy of the Entity containing only tags at the supplied cardinality.
func (Entity) GetTags ¶
func (e Entity) GetTags(cardinality TagCardinality) []string
GetTags flattens all tags from all cardinalities into a single slice of tag strings.
type EntityEvent ¶
EntityEvent is an event generated when an entity is added, modified or deleted. It contains the event type and the new entity.
type EntityID ¶
type EntityID interface { // GetID returns a prefix-specific id (i.e. an ID unique given prefix) GetID() string // GetPrefix returns the prefix of the EntityID GetPrefix() EntityIDPrefix // String returns a string representation of EntityID under the format {prefix}://{id} String() string }
EntityID represents a tagger entityID An EntityID should be identified by a prefix and an id, and is represented as {prefix}://{id}
func NewEntityID ¶
func NewEntityID(prefix EntityIDPrefix, id string) EntityID
NewEntityID builds and returns an EntityID object based on plain string uid Currently, it defaults to the default implementation of EntityID as a plain string
func NewEntityIDFromString ¶
NewEntityIDFromString constructs EntityID from a plain string id
type EntityIDPrefix ¶
type EntityIDPrefix string
EntityIDPrefix represents the prefix of a TagEntity id
const ( // ContainerID is the prefix `container_id` ContainerID EntityIDPrefix = "container_id" // ContainerImageMetadata is the prefix `container_image_metadata` ContainerImageMetadata EntityIDPrefix = "container_image_metadata" // ECSTask is the prefix `ecs_task` ECSTask EntityIDPrefix = "ecs_task" // Host is the prefix `host` Host EntityIDPrefix = "host" // KubernetesDeployment is the prefix `deployment` KubernetesDeployment EntityIDPrefix = "deployment" // KubernetesMetadata is the prefix `kubernetes_metadata` KubernetesMetadata EntityIDPrefix = "kubernetes_metadata" // KubernetesPodUID is the prefix `kubernetes_pod_uid` KubernetesPodUID EntityIDPrefix = "kubernetes_pod_uid" // Process is the prefix `process` Process EntityIDPrefix = "process" )
func (EntityIDPrefix) ToUID ¶
func (e EntityIDPrefix) ToUID(id string) string
ToUID builds a unique id from the passed id if the passed id is empty, an empty string is returned else it returns `{entityPrefix}://{id}`
type EventType ¶
type EventType int
EventType is a type of event, triggered when an entity is added, modified or deleted.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a subscription filter for the tagger
func NewMatchAllFilter ¶
func NewMatchAllFilter() *Filter
NewMatchAllFilter returns a filter that matches any prefix
func (*Filter) GetCardinality ¶
func (f *Filter) GetCardinality() TagCardinality
GetCardinality returns the filter cardinality If the filter is nil, High cardinality is returned
func (*Filter) GetPrefixes ¶
func (f *Filter) GetPrefixes() map[EntityIDPrefix]struct{}
GetPrefixes returns the prefix set of the filter If the filter is nil, a set containing all possible prefixes is returned
func (*Filter) MatchesPrefix ¶
func (f *Filter) MatchesPrefix(prefix EntityIDPrefix) bool
MatchesPrefix returns whether or not the filter matches the prefix passed as argument
type FilterBuilder ¶
type FilterBuilder struct {
// contains filtered or unexported fields
}
FilterBuilder builds a tagger subscriber filter based on include/exclude rules
func NewFilterBuilder ¶
func NewFilterBuilder() *FilterBuilder
NewFilterBuilder returns a new empty filter builder
func (*FilterBuilder) Build ¶
func (fb *FilterBuilder) Build(card TagCardinality) *Filter
Build builds a new Filter object based on the calls to Include and Exclude If the builder only excludes prefixes, the created filter will match any prefix except for the excluded ones. If the builder only includes prefixes, the created filter will match only the prefixes included in the builder. If the builder includes prefixes and excludes prefixes, the created filter will match only prefixes that are included but a not excluded in the builder If the builder has neither included nor excluded prefixes, it will match all prefixes by default
func (*FilterBuilder) Exclude ¶
func (fb *FilterBuilder) Exclude(prefixes ...EntityIDPrefix) *FilterBuilder
Exclude excludes the specified prefixes from the filter
func (*FilterBuilder) Include ¶
func (fb *FilterBuilder) Include(prefixes ...EntityIDPrefix) *FilterBuilder
Include includes the specified prefixes in the filter
type ObjectStore ¶
type ObjectStore[V any] interface { // Get returns an object with the specified entity ID if it exists in the store Get(EntityID) (V, bool) // Set sets a given entityID to a given object in the store Set(EntityID, V) // Unset unsets a given entityID in the store Unset(EntityID) // Size returns the total number of objects in the store Size() int // ListObjects returns a slice containing objects of the store matching the filter ListObjects(*Filter) []V // ForEach applies a given function to each object in the store matching the filter ForEach(*Filter, ApplyFunc[V]) }
ObjectStore is a generic interface used as a key-value store in different tagstore implementations The key is of type EntityID
type TagCardinality ¶
type TagCardinality int
TagCardinality indicates the cardinality-level of a tag. It can be low cardinality (in the host count order of magnitude) orchestrator cardinality (tags that change value for each pod, task, etc.) high cardinality (typically tags that change value for each web request, each container, etc.)
const ( LowCardinality TagCardinality = iota OrchestratorCardinality HighCardinality )
List of possible container cardinality
func StringToTagCardinality ¶
func StringToTagCardinality(c string) (TagCardinality, error)
StringToTagCardinality extracts a TagCardinality from a string. In case of failure to parse, returns an error and defaults to Low.
type TagInfo ¶
type TagInfo struct { Source string // source collector's name EntityID EntityID // entity id for lookup HighCardTags []string // high cardinality tags that can create a lot of different timeseries (typically one per container, user request, etc.) OrchestratorCardTags []string // orchestrator cardinality tags that have as many combination as pods/tasks LowCardTags []string // low cardinality tags safe for every pipeline StandardTags []string // the discovered standard tags (env, version, service) for the entity DeleteEntity bool // true if the entity is to be deleted from the store ExpiryDate time.Time // keep in cache until expiryDate }
TagInfo holds the tag information for a given entity and source. It's meant to be created from collectors and read by the store.
type TaggerListEntity ¶
TaggerListEntity holds the tagging info about an entity
type TaggerListResponse ¶
type TaggerListResponse struct {
Entities map[string]TaggerListEntity
}
TaggerListResponse holds the tagger list response