models

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTableFormatter

func NewTableFormatter() table.Writer

NewTableFormatter creates a writer for table format.

Types

type Exemplar added in v0.0.5

type Exemplar struct {
	TraceID  string `json:"traceId"`
	SpanID   string `json:"spanId"`
	Duration int64  `json:"duration"`
}

type Field

type Field struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Field represents field metadata

type Metadata

type Metadata struct {
	Type   string `json:"type"`
	Values any    `json:"values"` // field=>[]Field, else []string
}

Metadata represents metadata query result model.

func (*Metadata) ToTable

func (m *Metadata) ToTable() (rows int, tableStr string)

ToTable returns metadata list as table if it has value, else return empty string.

type NodeStats

type NodeStats struct {
	Node       string        `json:"node"`
	WaitCost   int64         `json:"waitCost,omitempty"` // wait intermediate or leaf response duration
	WaitStart  int64         `json:"waitStart,omitempty"`
	WaitEnd    int64         `json:"waitEnd,omitempty"`
	NetPayload int64         `json:"netPayload,omitempty"`
	TotalCost  int64         `json:"totalCost"`
	Start      int64         `json:"start"`
	End        int64         `json:"end"`
	Stages     []*StageStats `json:"stages,omitempty"`

	Children []*NodeStats `json:"children,omitempty"`
}

NodeStats represents query stats of node.

func (*NodeStats) ToTable

func (s *NodeStats) ToTable() (rows int, tableStr string)

ToTable returns the result of query as table if it has value, else return empty string.

type OperatorStats

type OperatorStats struct {
	Identifier string      `json:"identifier"`
	Start      int64       `json:"start"`
	End        int64       `json:"end"`
	Cost       int64       `json:"cost"`
	Stats      interface{} `json:"stats,omitempty"`
	ErrMsg     string      `json:"errMsg,omitempty"`
}

OperatorStats represents the stats of operator.

type Points

type Points struct {
	Points map[int64]float64 `json:"points,omitempty"`
}

Points represents the data points of the field

func NewPoints

func NewPoints() *Points

NewPoints creates the data point

func (*Points) AddPoint

func (p *Points) AddPoint(timestamp int64, value float64)

AddPoint adds point

type ResultSet

type ResultSet struct {
	Stats      *NodeStats `json:"stats,omitempty"`
	Namespace  string     `json:"namespace,omitempty"`
	MetricName string     `json:"metricName,omitempty"`
	GroupBy    []string   `json:"groupBy,omitempty"`
	Fields     []string   `json:"fields,omitempty"`
	Series     []*Series  `json:"series,omitempty"`
	StartTime  int64      `json:"startTime,omitempty"`
	EndTime    int64      `json:"endTime,omitempty"`
	Interval   int64      `json:"interval,omitempty"`
}

ResultSet represents the query result set

func NewResultSet

func NewResultSet() *ResultSet

NewResultSet creates a new result set

func (*ResultSet) AddSeries

func (rs *ResultSet) AddSeries(series *Series)

AddSeries adds a new series

func (*ResultSet) ToTable

func (rs *ResultSet) ToTable() (rows int, tableStr string)

ToTable returns the result of query as table if it has value, else return empty string.

type Series

type Series struct {
	Tags      map[string]string                `json:"tags,omitempty"`
	Fields    map[string]map[int64]float64     `json:"fields,omitempty"`
	Exemplars map[string]map[int64][]*Exemplar `json:"exemplars,omitempty"`

	TagValues string `json:"-"` // return series in order by tag values
}

Series represents one time series for metric.

func NewSeries

func NewSeries(tags map[string]string, tagValues string) *Series

NewSeries creates a new series.

func (*Series) AddField

func (s *Series) AddField(fieldName string, points *Points)

AddField adds a field

type SeriesStats

type SeriesStats struct {
	NumOfSeries uint64 `json:"numOfSeries"`
}

SeriesStats represents the stats for series.

type StageStats

type StageStats struct {
	Identifier string           `json:"identifier"`
	Start      int64            `json:"start"`
	End        int64            `json:"end"`
	Cost       int64            `json:"cost"`
	State      string           `json:"state"`
	ErrMsg     string           `json:"errMsg"`
	Async      bool             `json:"async"`
	Operators  []*OperatorStats `json:"operators,omitempty"`

	Children []*StageStats `json:"children"`
}

StageStats represents the stats of stage.

type Stats

type Stats struct {
	TotalCost int64 `json:"totalCost"`
	Min       int64 `json:"min"`
	Max       int64 `json:"max"`
	Count     int   `json:"count"`
	Series    int   `json:"series,omitempty"`
}

Stats represents the time stats

type TableFormatter

type TableFormatter interface {
	// ToTable returns string value/row size for displaying result in terminal.
	ToTable() (rows int, tableStr string)
}

TableFormatter represents table formatter for displaying result in terminal.

Jump to

Keyboard shortcuts

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