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" )
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 MetricType ¶ added in v0.0.35
type MetricType string
const ( MetricRequestSizeBytes MetricType = "request_size_bytes" MetricRequestDurationSeconds MetricType = "request_duration_seconds" MetricRequestsTotal MetricType = "requests_total" MetricRequestsSlowTotal MetricType = "requests_slow_total" MetricRequestsInFlight MetricType = "requests_in_flight" MetricResponseSizeBytes MetricType = "response_size_bytes" MetricErrorsTotal MetricType = "errors_total" MetricEvent MetricType = "event" MetricSiteEvent MetricType = "site_event" MetricSummaryLatency MetricType = "summary_latency" )
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 Observe(reporter Reporter) Log(handler, method, code string, sendBytes, recvBytes, latency float64) RequestTotal(module, handler, method, code string) ResponseSize(module, handler, method, code string, length float64) RequestSize(module, handler, method, code string, length float64) RequestDurationSeconds(module, handler, method string, latency float64) SummaryLatencyLog(module, handler, method string, latency float64) ErrorsTotal(module, errors string) Event(module, event string) SiteEvent(module, event, site string) RequestsInFlight(module, state string, value float64) }
Metrics is the metrics interface for metrics
var DummyMetrics Metrics = dummyMetrics{}
type Recorder ¶ added in v0.0.33
type Recorder interface {
Record(metrics Metrics)
}
Recorder is an interface for recording various metrics.
type Reporter ¶ added in v0.0.33
type Reporter interface { // Context returns the context of the reporter. Context() context.Context // Handler returns the Handler in the endpoint associated with the metric. Handler() string // Method returns the HTTP method used for the Handler call. Method() string // Code returns the status code of the Handler response. Code() string // WriteSize returns the number of bytes write in the response. WriteSize() int64 // ReadSize returns the number of bytes read in the request. ReadSize() 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.
Click to show internal directories.
Click to hide internal directories.