metrics

package
v1.101.15 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package metrics defines a common interface for instrumenting applications and components to collect metrics.

See also:

  • github.com/Vonage/gosrvlib/pkg/metrics/statsd
  • github.com/Vonage/gosrvlib/pkg/metrics/prometheus

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 for Prometheus.
Package prometheus implements the metrics interface for Prometheus.
Package statsd implements the metrics interface for StatsD.
Package statsd implements the metrics interface for StatsD.

Jump to

Keyboard shortcuts

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