transformation

package
v0.15.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryTransform

type BinaryTransform interface {
	Evaluate(prev, curr Datapoint) Datapoint
}

BinaryTransform is a binary transformation that takes the previous and the current datapoint as input and produces a single datapoint as the transformation result. It can keep state if it requires.

type BinaryTransformFn

type BinaryTransformFn func(prev, curr Datapoint) Datapoint

BinaryTransformFn implements BinaryTransform as a function.

func (BinaryTransformFn) Evaluate

func (fn BinaryTransformFn) Evaluate(prev, curr Datapoint) Datapoint

Evaluate implements BinaryTransform as a function.

type Datapoint

type Datapoint struct {
	TimeNanos int64
	Value     float64
}

Datapoint is a metric data point containing a timestamp in Unix nanoseconds since epoch and a value.

func (Datapoint) IsEmpty

func (dp Datapoint) IsEmpty() bool

IsEmpty returns whether this is an empty datapoint.

type Op

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

Op represents a transform operation.

func (Op) BinaryTransform

func (o Op) BinaryTransform() (BinaryTransform, bool)

BinaryTransform returns the active binary transform if op is binary transform.

func (Op) Type

func (o Op) Type() Type

Type returns the op type.

func (Op) UnaryTransform

func (o Op) UnaryTransform() (UnaryTransform, bool)

UnaryTransform returns the active unary transform if op is unary transform.

type Type

type Type int

Type defines a transformation function.

const (
	UnknownType Type = iota
	Absolute
	PerSecond
	Increase
	Add
)

Supported transformation types.

func ParseType

func ParseType(str string) (Type, error)

ParseType parses a transformation type.

func (Type) BinaryTransform

func (t Type) BinaryTransform() (BinaryTransform, error)

BinaryTransform returns the binary transformation function associated with the transformation type if applicable, or an error otherwise.

func (*Type) FromProto

func (t *Type) FromProto(pb transformationpb.TransformationType) error

FromProto converts the protobuf message to a transformation type in place.

func (Type) IsBinaryTransform

func (t Type) IsBinaryTransform() bool

IsBinaryTransform returns whether this is a binary transformation.

func (Type) IsUnaryTransform

func (t Type) IsUnaryTransform() bool

IsUnaryTransform returns whether this is a unary transformation.

func (Type) IsValid

func (t Type) IsValid() bool

IsValid checks if the transformation type is valid.

func (Type) MarshalText added in v0.12.0

func (t Type) MarshalText() (text []byte, err error)

MarshalText serializes this type to its textual representation.

func (Type) MustBinaryTransform

func (t Type) MustBinaryTransform() BinaryTransform

MustBinaryTransform returns the binary transformation function associated with the transformation type if applicable, or an error otherwise.

func (Type) MustUnaryTransform

func (t Type) MustUnaryTransform() UnaryTransform

MustUnaryTransform returns the unary transformation function associated with the transformation type if applicable, or panics otherwise.

func (Type) NewOp

func (t Type) NewOp() (Op, error)

NewOp returns a constructed operation that is allocated once and can be reused.

func (Type) String

func (i Type) String() string

func (Type) ToProto

ToProto converts the transformation type to a protobuf message in place.

func (Type) UnaryTransform

func (t Type) UnaryTransform() (UnaryTransform, error)

UnaryTransform returns the unary transformation function associated with the transformation type if applicable, or an error otherwise.

func (*Type) UnmarshalText added in v0.12.0

func (t *Type) UnmarshalText(text []byte) error

UnmarshalText extracts this type from the textual representation

func (*Type) UnmarshalYAML

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

UnmarshalYAML unmarshals text-encoded data into an transformation type.

type UnaryTransform

type UnaryTransform interface {
	Evaluate(dp Datapoint) Datapoint
}

UnaryTransform is a unary transformation that takes a single datapoint as input and transforms it into a datapoint as output. It can keep state if it requires.

type UnaryTransformFn

type UnaryTransformFn func(dp Datapoint) Datapoint

UnaryTransformFn implements UnaryTransform as a function.

func (UnaryTransformFn) Evaluate

func (fn UnaryTransformFn) Evaluate(dp Datapoint) Datapoint

Evaluate implements UnaryTransform as a function.

Jump to

Keyboard shortcuts

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