Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // BindAddress describes the local IP address and port to bind the server // listen socket to. For example, "0.0.0.0:8080". BindAddress string // EnableProfiling can be used to enable Go profiling and set up HTTP // endpoints that, for example, can be queried with // go tool pprof <binary> http://<host>:<port>/debug/pprof/heap EnableProfiling bool }
Config describes a configuration for a HTTPServer.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer represents a HTTP/REST API server for a particular LogStore.
func NewHTTP ¶
func NewHTTP(serverConfig *Config, logStore logstore.LogStore) *HTTPServer
NewHTTP creates a new HTTP (REST API) server with a given configuration and backing LogStore. The LogStore is assumed to already be in a connected state.
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start() error
Start starts the HTTP server. If successful, this method will block until the server is stopped.
type MetricDimensions ¶
type MetricDimensions struct { // Method is the HTTP method used: GET/POST/... Method string // Path is the requested path e.g., /write Path string // StatusCode is the response code, e.g.: 200 StatusCode int }
MetricDimensions represent the dimensions over which request metrics are categorized. Each data point for a given metric (for example, total_requests) will be categorized into these dimensions, making it a data point in a time-series (a metric and a particular set of metric dimension values).
total_requests{method=POST,path=/write,statusCode=200} 6 total_requests{method=GET,path=/metrics,statusCode=200} 5
type MetricsMiddleware ¶
type MetricsMiddleware struct { TotalRequests map[MetricDimensions]int64 SumResponseTime map[MetricDimensions]float64 AvgResponseTime map[MetricDimensions]float64 // contains filtered or unexported fields }
MetricsMiddleware is a "middleware" intended to be added as an interceptor handler that is invoked prior and after a request is dispatched to its handler. It collects metrics about the request handling.
func NewMetricsMiddleware ¶
func NewMetricsMiddleware() *MetricsMiddleware
NewMetricsMiddleware creates a new metricsMiddleware.
func (*MetricsMiddleware) Intercept ¶
func (mw *MetricsMiddleware) Intercept(nextHandler http.Handler) http.Handler
Intercept is called by gorilla mux prior to passing the request through to the handling function `nextHandler`. Here, we time the request handling, log the request, and update the metric counters.
func (*MetricsMiddleware) Metrics ¶
func (mw *MetricsMiddleware) Metrics() *bytes.Buffer
Metrics returns a byte buffer containing a snapshot of the collected metrics thus far.