Help us shape the future of Go! Take the 2026 Go Developer Survey

metrics

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Protocol string `json:"protocol"`
}

Configuration to hold all metrics configuration values

func LoadConfiguration

func LoadConfiguration() (Configuration, error)

LoadConfiguration - Function to load the metrics configuration from JSON file

type Counter

type Counter struct {
	Count    int
	Interval int64
}

Counter will be used to keep track of a counter

type Metrics

type Metrics struct {
	Ready bool

	Host     string
	Port     int
	Protocol string
	Tag      string
	Timeout  time.Duration

	Counters map[string]Counter
	// contains filtered or unexported fields
}

Metrics will be used to send metrics to grafana via TCP or UDP

func CreateMetrics

func CreateMetrics(protocol string, host string, port int, tag string) (*Metrics, error)

CreateMetrics to initialize the metrics struct for TCP or UDP

func (*Metrics) Connect

func (metrics *Metrics) Connect() error

Connect to assign the connection object

func (*Metrics) ConnectAndSend

func (metrics *Metrics) ConnectAndSend(name string, value int)

ConnectAndSend to connect and submit a metric via TCP or UDP

func (*Metrics) Disconnect

func (metrics *Metrics) Disconnect() error

Disconnect closes the connection object

func (*Metrics) Inc

func (metrics *Metrics) Inc(name string)

Inc to increase the counter for a metric

func (*Metrics) Send

func (metrics *Metrics) Send(name string, value int) error

Send to submit a metric via TCP or UDP

Jump to

Keyboard shortcuts

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