ckey

package module
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equals

func Equals(a, b ContextKey) bool

Equals returns whether the two context keys are equal or not.

Types

type ContextKey

type ContextKey uint64

ContextKey is a non-cryptographic hash that allows to aggregate metrics from a same context together.

This implementation has been designed to remove all heap allocations from the intake in order to reduce GC pressure on high volumes.

Having int64/uint64 context keys mean that we will get better performances from the Go runtime while using them as map keys. This is thanks to the fast-path methods for map access and map assign with int64 keys. See for instance runtime.mapassign_fast64 or runtime.mapaccess2_fast64.

Note that Agent <= 6.19.0 were using a 128 bits hash, we've switched to 64 bits for better performances (map access) and because 128 bits were overkill in the first place. Note that benchmarks against fnv1a did not provide better performances (no inlining) nor did benchmarks with xxhash (slightly slower).

func (ContextKey) IsZero

func (k ContextKey) IsZero() bool

IsZero returns true if the key is at zero value

type KeyGenerator

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

KeyGenerator generates hash for the given name, hostname and tags. The tags don't have to be sorted and duplicated tags will be ignored while generating the hash. Not safe for concurrent usage.

func NewKeyGenerator

func NewKeyGenerator() *KeyGenerator

NewKeyGenerator creates a new key generator

func (*KeyGenerator) Generate

func (g *KeyGenerator) Generate(name, hostname string, tagsBuf *tagset.HashingTagsAccumulator) ContextKey

Generate returns the ContextKey hash for the given parameters. tagsBuf is re-arranged in place and truncated to only contain unique tags.

func (*KeyGenerator) GenerateWithTags

func (g *KeyGenerator) GenerateWithTags(name, hostname string, tagsBuf *tagset.HashingTagsAccumulator) (ContextKey, TagsKey)

GenerateWithTags returns the ContextKey and TagsKey hashes for the given parameters. tagsBuf is re-arranged in place and truncated to only contain unique tags.

func (*KeyGenerator) GenerateWithTags2

func (g *KeyGenerator) GenerateWithTags2(name, hostname string, l, r *tagset.HashingTagsAccumulator) (ContextKey, TagsKey, TagsKey)

GenerateWithTags2 returns the ContextKey and TagsKey hashes for the given parameters.

Tags from l, r are combined to produce the key and deduplicated, but most of the time left in their respective buffers.

type TagsKey

type TagsKey uint64

TagsKey is a non-cryptographic hash of only the tags in a context. See ContextKey.

Jump to

Keyboard shortcuts

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