metrics

package
v0.0.89 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 1 Imported by: 7

Documentation

Overview

Package metrics provides the metrics recorder

Package metrics provides the metrics recorder

Index

Constants

View Source
const (
	MetricLabelInstance = "instance"
	MetricLabelHandler  = "handler"
	MetricLabelCode     = "code"
	MetricLabelMethod   = "method"
	MetricLabelModule   = "module"
	MetricLabelErrors   = "errors"
	MetricLabelEvent    = "event"
	MetricLabelSite     = "site"
	MetricLabelState    = "state"
)

Variables

This section is empty.

Functions

func MetricLabelNames added in v0.0.38

func MetricLabelNames(metricType MetricType) []string

MetricLabelNames returns the labels for the given metric type

func MetricLabels added in v0.0.35

func MetricLabels() map[MetricType][]string

MetricLabels returns the labels for the given metric type

Types

type MetricData added in v0.0.46

type MetricData struct {
	Type     MetricType
	TraceID  string
	Endpoint string
	Method   string
	Code     int
	SendSize int64
	RecvSize int64
	Latency  float64
	Succeed  bool
}

type MetricType added in v0.0.35

type MetricType string
const (
	//MetricRequestSizeBytes       MetricType = "request_size_bytes"       // MetricRequestSizeBytes is the request size in bytes
	//MetricRequestDurationSeconds MetricType = "request_duration_seconds" // MetricRequestDurationSeconds is the request duration in seconds
	//MetricRequestsTotal          MetricType = "requests_total"           // MetricRequestsTotal is the total number of requests
	//MetricRequestsSlowTotal      MetricType = "requests_slow_total"      // MetricRequestsSlowTotal is the total number of slow requests
	//MetricRequestsInFlight       MetricType = "requests_in_flight"       // MetricRequestsInFlight is the number of requests in flight
	//MetricResponseSizeBytes      MetricType = "response_size_bytes"      // MetricResponseSizeBytes is the response size in bytes
	//MetricErrorsTotal            MetricType = "errors_total"             // MetricErrorsTotal is the total number of errors
	//MetricEvent                  MetricType = "event"                    // MetricEvent is the event
	//MetricSiteEvent              MetricType = "site_event"               // MetricSiteEvent is the site event
	//MetricSummaryLatency         MetricType = "summary_latency"          // MetricSummaryLatency is the summary latency
	MetricUptime                  MetricType = "uptime"
	MetricRequestsTotal           MetricType = "requests_total"
	MetricRequestsDurationSeconds MetricType = "requests_duration_seconds"
	MetricRequestsInFlight        MetricType = "requests_in_flight"
	MetricRequestsSlowTotal       MetricType = "requests_slow_total"
	MetricCounterSendBytes        MetricType = "counter_send_bytes"
	MetricCounterRecvBytes        MetricType = "counter_recv_bytes"
	MetricHistogramLatency        MetricType = "histogram_latency"
	MetricSummaryLatency          MetricType = "summary_latency"
	MetricCounterException        MetricType = "counter_exception"
	MetricCounterEvent            MetricType = "counter_event"
	MetricCounterSiteEvent        MetricType = "counter_site_event"
)

func (MetricType) String added in v0.0.35

func (m MetricType) String() string

type Metrics

type Metrics interface {
	Enabled() bool // Enabled returns whether metrics is enabled
	Disable()
	Observe(ctx context.Context, data MetricData)
	Log(ctx context.Context, handler, method string, code int, sendBytes, recvBytes int64, latency float64)
}

Metrics is the metrics interface for metrics

type Recorder added in v0.0.33

type Recorder interface {
	RequestTotal(module, handler, method, code string)
	CounterSendBytes(module, handler, method, code string, length int64)
	CounterRecvBytes(module, handler, method, code string, length int64)
	RequestDurationSeconds(module, handler, method string, latency int64)
	SummaryLatencyLog(module, handler, method string, latency int64)
	CounterException(module, errors string)
	CounterEvent(module, event string)
	CounterSiteEvent(module, event, site string)
	RequestsInFlight(module, state string, value int64)
}

Recorder is an interface for recording various metrics.

Jump to

Keyboard shortcuts

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