model

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type       string
	Timestamp  int64
	Attributes map[string]any
}

Event model

func NewEvent

func NewEvent(eventType string, attributes map[string]any, timestamp time.Time) Event

Make a event.

type Log

type Log struct {
	Message    string
	Timestamp  int64
	Attributes map[string]interface{}
}

Log model variant.

func NewLog

func NewLog(message string, attributes map[string]interface{}, timestamp time.Time) Log

Make a log.

type Metric

type Metric struct {
	Name       string
	Type       MetricType
	Value      Numeric
	Interval   time.Duration
	Timestamp  int64
	Attributes map[string]interface{}
}

Metric model

func NewCountMetric

func NewCountMetric(name string, value Numeric, interval time.Duration, timestamp time.Time) Metric

Make a count metric. If interval is 0 the counter is cumulative. Otherwise is delta.

func NewGaugeMetric

func NewGaugeMetric(name string, value Numeric, timestamp time.Time) Metric

Make a gauge metric.

type MetricType

type MetricType int
const (
	Gauge MetricType = iota
	Count
	Summary
)

type Numeric

type Numeric struct {
	IntOrFlt bool // true = Int, false = Float
	IntVal   int64
	FltVal   float64
}

Numeric model.

func MakeNumeric

func MakeNumeric(val any) Numeric

Make a Numeric from either an int, int64 or float64. Other types will cause a panic.

func (*Numeric) Float

func (n *Numeric) Float() float64

Get float from Numeric.

func (*Numeric) Int

func (n *Numeric) Int() int64

Get int from Numeric.

func (*Numeric) IsFloat

func (n *Numeric) IsFloat() bool

Numeric holds a float.

func (*Numeric) IsInt

func (n *Numeric) IsInt() bool

Numeric holds an integer.

func (*Numeric) Value

func (n *Numeric) Value() any

Get whatever it is.

Jump to

Keyboard shortcuts

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