metric

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// EndpointFieldName is the Prometheus label for the request endpoint.
	EndpointFieldName = "endpoint"

	// CodeFieldName is the Prometheus label for the HTTP status code.
	CodeFieldName = "code"
)

Variables

View Source
var (
	// RequestCountComponent is a Compogo component that provides
	// HTTP request count metrics middleware.
	RequestCountComponent = &component.Component{
		Init: component.StepFunc(func(container container.Container) error {
			return container.Provide(NewRequestCount)
		}),
	}

	// DurationComponent is a Compogo component that provides
	// HTTP request duration metrics middleware.
	DurationComponent = &component.Component{
		Init: component.StepFunc(func(container container.Container) error {
			return container.Provide(NewDuration)
		}),
	}
)

Functions

This section is empty.

Types

type Duration

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

Duration is middleware that measures HTTP request duration. It exports a histogram metric: compogo_http_server_duration_seconds{app, endpoint}

func NewDuration

func NewDuration(appConfig *compogo.Config) *Duration

NewDuration creates a new Duration middleware. The appConfig provides the application name for the metric label.

func (*Duration) Middleware

func (middleware *Duration) Middleware(next http.Handler) http.Handler

Middleware implements the http.Middleware interface. It measures the duration of the request and records it in the histogram.

type RequestCount

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

RequestCount is middleware that counts HTTP requests by status code and endpoint. It exports a counter metric: compogo_http_server_requests_total{app, code, endpoint}

func NewRequestCount

func NewRequestCount(appConfig *compogo.Config) *RequestCount

NewRequestCount creates a new RequestCount middleware. The appConfig provides the application name for the metric label.

func (*RequestCount) Middleware

func (middleware *RequestCount) Middleware(next http.Handler) http.Handler

Middleware implements the http.Middleware interface. It increments the counter after the request completes.

Jump to

Keyboard shortcuts

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