metrics

package
v0.0.44 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 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

func MetricLabelNames(metricType MetricType) []string

MetricLabelNames returns the labels for the given metric type

func MetricLabels

func MetricLabels() map[MetricType][]string

MetricLabels returns the labels for the given metric type

Types

type MetricType

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

func (m MetricType) String() string

type Metrics

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

Metrics is the metrics interface for metrics

type Recorder

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.

type Report added in v0.0.43

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

Jump to

Keyboard shortcuts

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