Documentation ¶
Index ¶
Constants ¶
const GRPCMetrics = "grpc"
const HTTPMetrics = "http"
const (
MetricsPrometheusPath = "/metrics/prometheus"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
Handler handles HTTP requests to health and version endpoints.
func NewHandler ¶
NewHandler instantiates a handler.
func (*Handler) Metrics ¶
func (h *Handler) Metrics(rw http.ResponseWriter, r *http.Request, _ httprouter.Params)
Metrics outputs prometheus metrics
swagger:route GET /metrics/prometheus metadata prometheus
Get snapshot metrics from the service. If you're using k8s, you can then add annotations to your deployment like so:
``` metadata:
annotations: prometheus.io/port: "4434" prometheus.io/path: "/metrics/prometheus"
```
Produces: - plain/text Responses: 200: emptyResponse
func (*Handler) SetRoutes ¶
func (h *Handler) SetRoutes(r *httprouter.Router)
SetRoutes registers this handler's routes.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics prototypes
func NewMetrics ¶
NewMetrics creates new custom Prometheus metrics
func (*Metrics) Collect ¶ added in v0.0.279
func (h *Metrics) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*Metrics) Describe ¶ added in v0.0.279
func (h *Metrics) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (Metrics) Instrument ¶ added in v0.0.279
func (h Metrics) Instrument(rw http.ResponseWriter, next http.HandlerFunc, endpoint string) http.HandlerFunc
Instrument will instrument any http.HandlerFunc with custom metrics
type MetricsManager ¶
type MetricsManager struct {
// contains filtered or unexported fields
}
func NewMetricsManager ¶
func NewMetricsManager(app, version, hash, buildTime string) *MetricsManager
func NewMetricsManagerWithPrefix ¶ added in v0.0.279
func NewMetricsManagerWithPrefix(app, metricsPrefix, version, hash, buildTime string) *MetricsManager
NewMetricsManagerWithPrefix creates MetricsManager that uses metricsPrefix parameters as a prefix for all metrics registered within this middleware. Constants HttpMetrics or GrpcMetrics can be used respectively. Setting empty string in metricsPrefix will be equivalent to calling NewMetricsManager.
func (*MetricsManager) RegisterRouter ¶
func (pmm *MetricsManager) RegisterRouter(router *httprouter.Router)
func (*MetricsManager) ServeHTTP ¶
func (pmm *MetricsManager) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Main middleware method to collect metrics for Prometheus.