ckey

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 3 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 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 we've benchmarked against xxhash64 which should be slightly faster, but the Go compiler is not inlining xxhash sum methods whereas it is inlining the murmur3 implementation, providing better performances overall. Note that benchmarks against fnv1a did not provide better performances (no inlining).

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 key 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, tags []string) ContextKey

Generate returns the ContextKey hash for the given parameters. The tags array is sorted in place to avoid heap allocations.

Jump to

Keyboard shortcuts

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