metrics

package
v0.0.0-...-b507f95 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

A module for defining a metric schema and auxiliary functions for interacting with it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricType

type MetricType string
const (
	Gauge   MetricType = "gauge"
	Counter MetricType = "counter"
)

func (MetricType) IsValid

func (mt MetricType) IsValid() bool

type Metrics

type Metrics struct {
	ID    string     `json:"id" db:"name"`                         // имя метрики
	MType MetricType `json:"type" db:"m_type"`                     // параметр, принимающий значение gauge или counter
	Delta *int64     `json:"delta,omitempty" db:"delta,omitempty"` // значение метрики в случае передачи counter
	Value *float64   `json:"value,omitempty" db:"value,omitempty"` // значение метрики в случае передачи gauge
}

Metrics a structure for storing information about metrics.

func NewMetric

func NewMetric(metricType, metricName, metricValue string) (*Metrics, error)

func (*Metrics) GetValue

func (m *Metrics) GetValue() (val string)

func (*Metrics) UnmarshalJSON

func (m *Metrics) UnmarshalJSON(data []byte) error

UnmarshalJSON overriding the standard method to cast to the MetricType type.

func (*Metrics) ValidateType

func (m *Metrics) ValidateType() error

ValidateType checks the validity of the metric type.

func (*Metrics) ValidateValue

func (m *Metrics) ValidateValue() error

ValidateValue checks the value depending on the type of metric.

Jump to

Keyboard shortcuts

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