types

package
v0.0.0-...-e834411 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 71

Documentation

Overview

Package types contains miscellaneous structs and interfaces used throughout tsmon. They live here to avoid circular dependencies between other packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	MetricInfo
	MetricMetadata
	CellData
}

Cell is the smallest unit of data recorded by tsmon. Metrics can be thought of as multi-dimensional maps (with fields defining the dimensions) - a Cell is one value in that map, with information about its fields and its type.

type CellData

type CellData struct {
	FieldVals []any
	Target    Target
	ResetTime time.Time
	Value     any
}

CellData contains the value of a single cell.

type DistributionMetric

type DistributionMetric interface {
	Metric

	Bucketer() *distribution.Bucketer
}

DistributionMetric is the low-level interface provided by all distribution metrics. It has a Bucketer which is responsible for assigning buckets to samples. Concrete types are defined in the "metrics" package.

type Metric

type Metric interface {
	Info() MetricInfo
	Metadata() MetricMetadata
}

Metric is the low-level interface provided by all metrics. Concrete types are defined in the "metrics" package.

type MetricDataUnits

type MetricDataUnits string

MetricDataUnits are enums for the units of metrics data.

const (
	Unknown      MetricDataUnits = ""
	Seconds      MetricDataUnits = "s"
	Milliseconds MetricDataUnits = "ms"
	Microseconds MetricDataUnits = "us"
	Nanoseconds  MetricDataUnits = "ns"
	Bits         MetricDataUnits = "B"
	Bytes        MetricDataUnits = "By"

	Kilobytes MetricDataUnits = "kBy"  // 1000 bytes (not 1024).
	Megabytes MetricDataUnits = "MBy"  // 1e6 (1,000,000) bytes.
	Gigabytes MetricDataUnits = "GBy"  // 1e9 (1,000,000,000) bytes.
	Kibibytes MetricDataUnits = "kiBy" // 1024 bytes.
	Mebibytes MetricDataUnits = "MiBy" // 1024^2 (1,048,576) bytes.
	Gibibytes MetricDataUnits = "GiBy" // 1024^3 (1,073,741,824) bytes.

	// * Extended Units
	AmpUnit           MetricDataUnits = "A"
	MilliampUnit      MetricDataUnits = "mA"
	DegreeCelsiusUnit MetricDataUnits = "Cel"
)

Units of metrics data.

func (MetricDataUnits) IsSpecified

func (u MetricDataUnits) IsSpecified() bool

IsSpecified returns true if a unit annotation has been specified for a given metric.

func (MetricDataUnits) IsTime

func (u MetricDataUnits) IsTime() bool

IsTime returns true if the unit is time.

type MetricInfo

type MetricInfo struct {
	Name        string
	Description string
	Fields      []field.Field
	ValueType   ValueType
	TargetType  TargetType
}

MetricInfo contains the definition of a metric.

type MetricMetadata

type MetricMetadata struct {
	Units MetricDataUnits // the unit of recorded data for a given metric.
}

MetricMetadata contains user-provided metadata for a metric.

type Target

type Target interface {
	// TODO(1026140): the hash and proto of a Target object should be created
	// at the time of the object creation.
	PopulateProto(d *pb.MetricsCollection)
	Hash() uint64
	Clone() Target
	Type() TargetType
}

A Target knows how to put information about itself in a MetricsData message.

type TargetType

type TargetType struct {
	// Name is the name of the TargeType that can be given to --target-type
	// command line option.
	Name string
	// Type is the reflect.Type of the Target struct.
	Type reflect.Type
}

TargetType represents the type of a Target, which identifies a metric with the name.

A metric is identified by (metric.info.name, metric.info.target_type).

func (TargetType) String

func (tt TargetType) String() string

type ValueType

type ValueType int

ValueType is an enum for the type of a metric.

const (
	NonCumulativeIntType ValueType = iota
	CumulativeIntType
	NonCumulativeFloatType
	CumulativeFloatType
	StringType
	BoolType
	NonCumulativeDistributionType
	CumulativeDistributionType
)

Types of metric values.

func (ValueType) IsCumulative

func (v ValueType) IsCumulative() bool

IsCumulative returns true if this is a cumulative metric value type.

func (ValueType) String

func (v ValueType) String() string

Jump to

Keyboard shortcuts

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