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 ¶
func MetricLabels ¶ added in v0.0.35
func MetricLabels() map[MetricType][]string
MetricLabels returns the labels for the given metric type
func MetricTypeLabels ¶ added in v0.0.35
func MetricTypeLabels(metricType MetricType) []string
MetricTypeLabels returns the labels for the given metric type
Types ¶
type Config ¶ added in v0.0.35
type Config struct { Enable bool // Enable specifies if the server is enabled. ListenPort int // ListenPort is the port on which the server listens. ReadTimeout time.Duration // ReadTimeout is the duration for reading the entire request. WriteTimeout time.Duration // WriteTimeout is the duration for writing the entire response. MaxHeaderBytes int // MaxHeaderBytes is the maximum number of bytes the server will read parsing the request header. DurationBuckets []float64 // DurationBuckets are the buckets for histogram observations based on time. SizeBuckets []float64 // SizeBuckets are the buckets for histogram observations based on size. Namespace string // Namespace is the identifier for metrics in the namespace. SubSystem string // SubSystem is the subsystem identifier for metrics. Buckets []float64 // Buckets are the predefined histogram buckets. Objectives map[float64]float64 // Objectives contains quantile ranks and their error allowances. DefaultCollect bool // DefaultCollect specifies if metrics should be collected by default. BasicUserName string // BasicUserName is the username for basic authentication. BasicPassword string // BasicPassword is the password for basic authentication. MetricLabels map[MetricType][]string // MetricLabels is the set of labels for each metric type. LogMethod map[string]struct{} // LogMethod is the set of methods to log. LogAPI map[string]struct{} // LogAPI is the set of APIs to log. Application string // Application is the name of the application. }
Config represents the configuration for the Service server.
func DefaultConfig ¶ added in v0.0.35
func DefaultConfig() *Config
DefaultConfig returns the default configuration for the Service server.
type MetricType ¶ added in v0.0.35
type MetricType string
const ( MetricRequestTotal MetricType = "request_total" MetricSendBytes MetricType = "send_bytes" MetricRecvBytes MetricType = "recv_bytes" MetricException MetricType = "exception" MetricEvent MetricType = "event" MetricSiteEvent MetricType = "site_event" MetricHistogramLatency MetricType = "histogram_latency" MetricSummaryLatency MetricType = "summary_latency" MetricGaugeState MetricType = "gauge_state" )
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(api, method, code string, sendBytes, recvBytes, latency float64) RequestLog(module, api, method, code string) SendBytesLog(module, api, method, code string, length float64) RecvBytesLog(module, api, method, code string, length float64) HistogramLatencyLog(module, api, method string, latency float64) SummaryLatencyLog(module, api, method string, latency float64) ExceptionLog(module, exception string) EventLog(module, event string) SiteEventLog(module, event, site string) StateLog(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 // 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.
Click to show internal directories.
Click to hide internal directories.