Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefBuckets contains the default buckets for the Duration histogram metric DefBuckets = []float64{.001, .01, .1, 1, 10} )
Functions ¶
This section is empty.
Types ¶
type Application ¶ added in v0.2.0
type Application struct {
Name string
Port int
Handlers []Handler
Metrics
// contains filtered or unexported fields
}
Application runs an HTTP Server for one or more application Handlers
func (*Application) GetPort ¶ added in v0.2.0
func (s *Application) GetPort() int
GetPort returns the TCP port on which the HTTP server is accepting connections. Useful when creating the server for a dynamic listening port
func (*Application) Run ¶ added in v0.2.0
func (a *Application) Run() error
Run starts the HTTP Server
type Handler ¶
type Handler struct {
// Path of the endpoint (e.g. "/health"). Must include the leading /
Path string
// Handler that implements the endpoint
Handler http.Handler
// Methods that the handler should support. If empty, http.MethodGet is the default
Methods []string
}
Handler contains an endpoint to be registered in the Server's HTTP server
type Metrics ¶
type Metrics struct {
// RequestCounter records the number of times a handler was called. This is a prometheus.CounterVec with three labels: "method", "path" and "code".
// By default, a metric called "http_requests_totals" will be used
RequestCounter *prometheus.CounterVec
// DurationHistogram records the latency of each handler call. This is a prometheus.HistogramVec with two labels: "method" and "path".
// By default, a metric called "http_requests_duration_seconds" will be used, with DefBuckets as the histogram's buckets.
DurationHistogram *prometheus.HistogramVec
}
Metrics contains the metrics that will be captured while serving HTTP requests. If these are not provided then Server will create default metrics and register them with Prometheus' default registry.
type Prometheus ¶
Prometheus runs a Prometheus metrics server
func (*Prometheus) GetPort ¶ added in v0.2.0
func (s *Prometheus) GetPort() int
GetPort returns the TCP port on which the HTTP server is accepting connections. Useful when creating the server for a dynamic listening port
func (*Prometheus) Run ¶ added in v0.2.0
func (p *Prometheus) Run() error
Run starts the HTTP Server
type Server ¶
type Server struct {
Application
Prometheus
}
Server combines a Prometheus metrics server with an Application server. Both servers need to be using different TCP ports.