aggregation

package
v0.0.0-...-5c6aed3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2018 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// IDLen is the length of the ID.
	// The IDLen will be 1 when maxTypeID <= 63.
	IDLen = (maxTypeID)/64 + 1
)

Variables

This section is empty.

Functions

func EmptyTransform

func EmptyTransform(b []byte) []byte

EmptyTransform transforms the input byte slice to an empty byte slice.

func NoOpTransform

func NoOpTransform(b []byte) []byte

NoOpTransform returns the input byte slice as is.

func SuffixTransform

func SuffixTransform(b []byte) []byte

SuffixTransform transforms the input byte slice to a suffix by prepending a dot at the beginning.

Types

type ID

type ID [IDLen]uint64

ID represents a compressed view of Types.

var (
	// DefaultID is a default ID.
	DefaultID ID
)

func CompressTypes

func CompressTypes(aggTypes ...Type) (ID, error)

CompressTypes compresses a list of aggregation types to an ID.

func MustCompressTypes

func MustCompressTypes(aggTypes ...Type) ID

MustCompressTypes compresses a list of aggregation types to an ID, it panics if an error was encountered.

func NewIDFromProto

func NewIDFromProto(input []aggregationpb.AggregationType) (ID, error)

NewIDFromProto creates an ID from proto.

func (ID) Contains

func (id ID) Contains(aggType Type) bool

Contains checks if the given aggregation type is contained in the aggregation id.

func (ID) Equal

func (id ID) Equal(other ID) bool

Equal checks whether two IDs are considered equal.

func (*ID) FromProto

func (id *ID) FromProto(pb aggregationpb.AggregationID) error

FromProto converts the protobuf message to an aggregation id in place.

func (ID) IsDefault

func (id ID) IsDefault() bool

IsDefault checks if the ID is the default aggregation type.

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of an ID.

func (ID) String

func (id ID) String() string

String is a string representation of the ID.

func (ID) ToProto

func (id ID) ToProto(pb *aggregationpb.AggregationID) error

ToProto converts the aggregation id to a protobuf message in place.

func (ID) Types

func (id ID) Types() (Types, error)

Types returns the aggregation types defined by the id.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON-encoded data into an ID.

func (*ID) UnmarshalYAML

func (id *ID) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals YAML-encoded data into an ID.

type IDCompressor

type IDCompressor interface {
	// Compress compresses a set of aggregation types into an aggregation id.
	Compress(aggTypes Types) (ID, error)

	// MustCompress compresses a set of aggregation types into an aggregation id,
	// and panics if an error is encountered.
	MustCompress(aggTypes Types) ID
}

IDCompressor can compress Types into an ID.

func NewIDCompressor

func NewIDCompressor() IDCompressor

NewIDCompressor returns a new IDCompressor.

type IDDecompressor

type IDDecompressor interface {
	// Decompress decompresses an aggregation id into a set of aggregation types.
	Decompress(id ID) (Types, error)

	// MustDecompress decompresses an aggregation id into a set of aggregation types,
	// and panics if an error is encountered.
	MustDecompress(id ID) Types
}

IDDecompressor can decompress ID.

func NewIDDecompressor

func NewIDDecompressor() IDDecompressor

NewIDDecompressor returns a new IDDecompressor.

func NewPooledIDDecompressor

func NewPooledIDDecompressor(pool TypesPool) IDDecompressor

NewPooledIDDecompressor returns a new pooled TypeDecompressor.

type QuantileTypeStringFn

type QuantileTypeStringFn func(quantile float64) []byte

QuantileTypeStringFn returns the type string for a quantile value.

type Type

type Type int

Type defines an aggregation function.

const (
	UnknownType Type = iota
	Last
	Min
	Max
	Mean
	Median
	Count
	Sum
	SumSq
	Stdev
	P10
	P20
	P30
	P40
	P50
	P60
	P70
	P80
	P90
	P95
	P99
	P999
	P9999
)

Supported aggregation types.

func NewTypeFromProto

func NewTypeFromProto(input aggregationpb.AggregationType) (Type, error)

NewTypeFromProto creates an aggregation type from a proto.

func ParseType

func ParseType(str string) (Type, error)

ParseType parses an aggregation type.

func (Type) ID

func (a Type) ID() int

ID returns the id of the Type.

func (Type) IsValid

func (a Type) IsValid() bool

IsValid checks if an Type is valid.

func (Type) IsValidForCounter

func (a Type) IsValidForCounter() bool

IsValidForCounter if an Type is valid for Counter.

func (Type) IsValidForGauge

func (a Type) IsValidForGauge() bool

IsValidForGauge if an Type is valid for Gauge.

func (Type) IsValidForTimer

func (a Type) IsValidForTimer() bool

IsValidForTimer if an Type is valid for Timer.

func (Type) MarshalJSON

func (a Type) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of an aggregation type.

func (Type) Proto

func (a Type) Proto() (aggregationpb.AggregationType, error)

Proto returns the proto of the aggregation type.

func (Type) Quantile

func (a Type) Quantile() (float64, bool)

Quantile returns the quantile represented by the Type.

func (Type) String

func (i Type) String() string

func (*Type) UnmarshalJSON

func (a *Type) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON-encoded data into an aggregation type.

func (*Type) UnmarshalYAML

func (a *Type) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals aggregation type from a string.

type TypeStringTransformFn

type TypeStringTransformFn func(typeString []byte) []byte

TypeStringTransformFn transforms the type string.

type Types

type Types []Type

Types is a list of Types.

var (

	// DefaultTypes is a default list of aggregation types.
	DefaultTypes Types

	// ValidTypes is the list of all the valid aggregation types.
	ValidTypes = map[Type]struct{}{
		Last:   emptyStruct,
		Min:    emptyStruct,
		Max:    emptyStruct,
		Mean:   emptyStruct,
		Median: emptyStruct,
		Count:  emptyStruct,
		Sum:    emptyStruct,
		SumSq:  emptyStruct,
		Stdev:  emptyStruct,
		P10:    emptyStruct,
		P20:    emptyStruct,
		P30:    emptyStruct,
		P40:    emptyStruct,
		P50:    emptyStruct,
		P60:    emptyStruct,
		P70:    emptyStruct,
		P80:    emptyStruct,
		P90:    emptyStruct,
		P95:    emptyStruct,
		P99:    emptyStruct,
		P999:   emptyStruct,
		P9999:  emptyStruct,
	}
)

func NewTypesFromProto

func NewTypesFromProto(input []aggregationpb.AggregationType) (Types, error)

NewTypesFromProto creates a list of aggregation types from a proto.

func ParseTypes

func ParseTypes(str string) (Types, error)

ParseTypes parses a list of aggregation types in the form of type1,type2,type3.

func (Types) Contains

func (aggTypes Types) Contains(aggType Type) bool

Contains checks if the given type is contained in the aggregation types.

func (Types) IsDefault

func (aggTypes Types) IsDefault() bool

IsDefault checks if the Types is the default aggregation type.

func (Types) IsValidForCounter

func (aggTypes Types) IsValidForCounter() bool

IsValidForCounter checks if the list of aggregation types is valid for Counter.

func (Types) IsValidForGauge

func (aggTypes Types) IsValidForGauge() bool

IsValidForGauge checks if the list of aggregation types is valid for Gauge.

func (Types) IsValidForTimer

func (aggTypes Types) IsValidForTimer() bool

IsValidForTimer checks if the list of aggregation types is valid for Timer.

func (Types) PooledQuantiles

func (aggTypes Types) PooledQuantiles(p pool.FloatsPool) ([]float64, bool)

PooledQuantiles returns all the quantiles found in the list of aggregation types. Using a floats pool if available.

A boolean will also be returned to indicate whether the returned float slice is from the pool.

func (Types) Proto

func (aggTypes Types) Proto() ([]aggregationpb.AggregationType, error)

Proto returns the proto of the aggregation types.

func (Types) String

func (aggTypes Types) String() string

String returns the string representation of the list of aggregation types.

type TypesAlloc

type TypesAlloc func() Types

TypesAlloc allocates new aggregation types.

type TypesConfiguration

type TypesConfiguration struct {
	// Default aggregation types for counter metrics.
	DefaultCounterAggregationTypes *Types `yaml:"defaultCounterAggregationTypes"`

	// Default aggregation types for timer metrics.
	DefaultTimerAggregationTypes *Types `yaml:"defaultTimerAggregationTypes"`

	// Default aggregation types for gauge metrics.
	DefaultGaugeAggregationTypes *Types `yaml:"defaultGaugeAggregationTypes"`

	// CounterTransformFnType configures the type string transformation function for counters.
	CounterTransformFnType *transformFnType `yaml:"counterTransformFnType"`

	// TimerTransformFnType configures the type string transformation function for timers.
	TimerTransformFnType *transformFnType `yaml:"timerTransformFnType"`

	// GaugeTransformFnType configures the type string transformation function for gauges.
	GaugeTransformFnType *transformFnType `yaml:"gaugeTransformFnType"`

	// Pool of aggregation types.
	AggregationTypesPool pool.ObjectPoolConfiguration `yaml:"aggregationTypesPool"`

	// Pool of quantile slices.
	QuantilesPool pool.BucketizedPoolConfiguration `yaml:"quantilesPool"`
}

TypesConfiguration contains configuration for aggregation types.

func (TypesConfiguration) NewOptions

func (c TypesConfiguration) NewOptions(instrumentOpts instrument.Options) (TypesOptions, error)

NewOptions creates a new Option.

type TypesOptions

type TypesOptions interface {

	// SetDefaultCounterAggregationTypes sets the default aggregation types for counters.
	SetDefaultCounterAggregationTypes(value Types) TypesOptions

	// DefaultCounterAggregationTypes returns the default aggregation types for counters.
	DefaultCounterAggregationTypes() Types

	// SetDefaultTimerAggregationTypes sets the default aggregation types for timers.
	SetDefaultTimerAggregationTypes(value Types) TypesOptions

	// DefaultTimerAggregationTypes returns the default aggregation types for timers.
	DefaultTimerAggregationTypes() Types

	// SetDefaultGaugeAggregationTypes sets the default aggregation types for gauges.
	SetDefaultGaugeAggregationTypes(value Types) TypesOptions

	// DefaultGaugeAggregationTypes returns the default aggregation types for gauges.
	DefaultGaugeAggregationTypes() Types

	// SetQuantileTypeStringFn sets the quantile type string function for timers.
	SetQuantileTypeStringFn(value QuantileTypeStringFn) TypesOptions

	// QuantileTypeStringFn returns the quantile type string function for timers.
	QuantileTypeStringFn() QuantileTypeStringFn

	// SetCounterTypeStringTransformFn sets the transformation function for counter type strings.
	SetCounterTypeStringTransformFn(value TypeStringTransformFn) TypesOptions

	// CounterTypeStringTransformFn returns the transformation function for counter type strings.
	CounterTypeStringTransformFn() TypeStringTransformFn

	// SetTimerTypeStringTransformFn sets the transformation function for timer type strings.
	SetTimerTypeStringTransformFn(value TypeStringTransformFn) TypesOptions

	// TimerTypeStringTransformFn returns the transformation function for timer type strings.
	TimerTypeStringTransformFn() TypeStringTransformFn

	// SetGaugeTypeStringTransformFn sets the transformation function for gauge type strings.
	SetGaugeTypeStringTransformFn(value TypeStringTransformFn) TypesOptions

	// GaugeTypeStringTransformFn returns the transformation function for gauge type strings.
	GaugeTypeStringTransformFn() TypeStringTransformFn

	// SetTypesPool sets the aggregation types pool.
	SetTypesPool(pool TypesPool) TypesOptions

	// TypesPool returns the aggregation types pool.
	TypesPool() TypesPool

	// SetQuantilesPool sets the timer quantiles pool.
	SetQuantilesPool(pool pool.FloatsPool) TypesOptions

	// QuantilesPool returns the timer quantiles pool.
	QuantilesPool() pool.FloatsPool

	// TypeStringForCounter returns the type string for the aggregation type for counters.
	TypeStringForCounter(value Type) []byte

	// TypeStringForTimer returns the type string for the aggregation type for timers.
	TypeStringForTimer(value Type) []byte

	// TypeStringForGauge returns the type string for the aggregation type for gauges.
	TypeStringForGauge(value Type) []byte

	// TypeForCounter returns the aggregation type for given counter type string.
	TypeForCounter(value []byte) Type

	// TypeForTimer returns the aggregation type for given timer type string.
	TypeForTimer(value []byte) Type

	// TypeForGauge returns the aggregation type for given gauge type string.
	TypeForGauge(value []byte) Type

	// Quantiles returns the quantiles for timers.
	Quantiles() []float64

	// IsContainedInDefaultAggregationTypes checks if the given aggregation type is
	// contained in the default aggregation types for the metric type.
	IsContainedInDefaultAggregationTypes(at Type, mt metric.Type) bool
}

TypesOptions provides a set of options for aggregation types.

func NewTypesOptions

func NewTypesOptions() TypesOptions

NewTypesOptions returns a default TypesOptions.

type TypesPool

type TypesPool interface {
	// Init initializes the aggregation types pool.
	Init(alloc TypesAlloc)

	// Get gets an empty list of aggregation types from the pool.
	Get() Types

	// Put returns aggregation types to the pool.
	Put(value Types)
}

TypesPool provides a pool of aggregation types.

func NewTypesPool

func NewTypesPool(opts pool.ObjectPoolOptions) TypesPool

NewTypesPool creates a new pool for aggregation types.

Jump to

Keyboard shortcuts

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