prometheus

package
v0.0.431 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2022 License: Apache-2.0 Imports: 9 Imported by: 16

Documentation

Index

Constants

View Source
const GRPCMetrics = "grpc"
View Source
const HTTPMetrics = "http"
View Source
const (
	MetricsPrometheusPath = "/metrics/prometheus"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	H             herodot.Writer
	VersionString string
}

Handler handles HTTP requests to health and version endpoints.

func NewHandler

func NewHandler(
	h herodot.Writer,
	version string,
) *Handler

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 router)

SetRoutes registers this handler's routes.

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics prototypes

func NewMetrics

func NewMetrics(app, metricsPrefix, version, hash, date string) *Metrics

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL