metrics

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 2 Imported by: 7

Documentation

Overview

Package metrics provides the metrics recorder

Package metrics provides the metrics recorder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics interface {
	// Enabled returns whether metrics is enabled
	Enabled() bool

	// Observe records a metric using the provided Reporter
	Observe(reporter Reporter)

	// Recorder returns the Recorder for this Metrics instance
	Recorder() Recorder
}

Metrics is the metrics interface for metrics

type Recorder

type Recorder interface {
	// Log records the general metrics like API, method, code, sendBytes, recvBytes, and latency.
	Log(api, method, code string, sendBytes, recvBytes, latency float64)

	// RequestLog records the request details like module, API, method, and code.
	RequestLog(module, api, method, code string)

	// SendBytesLog records the bytes sent for a specific module, API, method, and code.
	SendBytesLog(module, api, method, code string, byte float64)

	// RecvBytesLog records the bytes received for a specific module, API, method, and code.
	RecvBytesLog(module, api, method, code string, byte float64)

	// HistogramLatencyLog records the latency in a histogram format for a specific module, API, and method.
	HistogramLatencyLog(module, api, method string, latency float64)

	// SummaryLatencyLog records the latency in a summary format for a specific module, API, and method.
	SummaryLatencyLog(module, api, method string, latency float64)

	// ExceptionLog records an exception event for a specific module and exception.
	ExceptionLog(module, exception string)

	// EventLog records a general event for a specific module and event.
	EventLog(module, event string)

	// SiteEventLog records a site-specific event for a specific module, event, and site.
	SiteEventLog(module, event, site string)

	// StateLog records the state value for a specific module and state.
	StateLog(module, state string, value float64)

	// ResetCounter resets any internal counters maintained by the recorder.
	ResetCounter()

	// RegisterCustomCollector allows registering a custom prometheus.Collector.
	RegisterCustomCollector(c prometheus.Collector)
}

Recorder is an interface for recording various metrics.

var DummyRecorder Recorder = dummyRecorder{}

type Reporter added in v0.0.33

type Reporter interface {
	// Context returns the context of the reporter.
	Context() context.Context
	// API returns the API endpoint associated with the metric.
	API() string
	// Method returns the HTTP method used for the API call.
	Method() string
	// Code returns the status code of the API response.
	Code() string
	// BytesWritten returns the number of bytes written in the response.
	BytesWritten() int64
	// BytesReceived returns the number of bytes received in the request.
	BytesReceived() int64
	// Succeed returns a boolean indicating if the request was successful.
	Succeed() bool
	// TraceID returns the unique trace ID associated with the request.
	TraceID() string
	// Latency returns the latency of the request in milliseconds.
	Latency() int64
}

Reporter is an interface that defines methods for reporting metrics.

Jump to

Keyboard shortcuts

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