metrics

package
v1.70.6 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package metrics defines a general interface for metrics instrumentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// InstrumentDB wraps a sql.DB to collect metrics.
	InstrumentDB(dbName string, db *sql.DB) error

	// InstrumentHandler wraps a http.Handler to collect metrics.
	InstrumentHandler(path string, handler http.HandlerFunc) http.Handler

	// InstrumentRoundTripper is a middleware that wraps the provided http.RoundTripper to observe the request result with default metrics.
	InstrumentRoundTripper(next http.RoundTripper) http.RoundTripper

	// MetricsHandlerFunc returns an http handler function to serve the metrics endpoint.
	MetricsHandlerFunc() http.HandlerFunc

	// IncLogLevelCounter counts the number of errors for each log severity level.
	IncLogLevelCounter(level string)

	// IncErrorCounter increments the number of errors by task, operation and error code.
	IncErrorCounter(task, operation, code string)

	// Close method.
	Close() error
}

Client is an interface type for the metrics functions.

type Default

type Default struct{}

Default is the default implementation for the Client interface.

func (*Default) Close

func (c *Default) Close() error

Close method.

func (*Default) IncErrorCounter

func (c *Default) IncErrorCounter(_, _, _ string)

IncErrorCounter is an empty function.

func (*Default) IncLogLevelCounter

func (c *Default) IncLogLevelCounter(_ string)

IncLogLevelCounter is an empty function.

func (*Default) InstrumentDB

func (c *Default) InstrumentDB(_ string, _ *sql.DB) error

InstrumentDB wraps a sql.DB to collect metrics.

func (*Default) InstrumentHandler

func (c *Default) InstrumentHandler(_ string, handler http.HandlerFunc) http.Handler

InstrumentHandler returns the input handler.

func (*Default) InstrumentRoundTripper

func (c *Default) InstrumentRoundTripper(next http.RoundTripper) http.RoundTripper

InstrumentRoundTripper returns the input Roundtripper.

func (*Default) MetricsHandlerFunc

func (c *Default) MetricsHandlerFunc() http.HandlerFunc

MetricsHandlerFunc returns an http handler function.

Directories

Path Synopsis
Package prometheus implements the metrics interface with Prometheus.
Package prometheus implements the metrics interface with Prometheus.
Package statsd implements the metrics interface with StatsD.
Package statsd implements the metrics interface with StatsD.

Jump to

Keyboard shortcuts

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