Documentation
¶
Index ¶
- func GetMetricHandler(opt ...HandlerOption) http.Handler
- func Middleware(options ...Option) gin.HandlerFunc
- type HandlerOption
- type Option
- func WithAggregateStatusCode(aggregate bool) Option
- func WithFilterPath(filter func(string, string) bool) Option
- func WithFilterRoutes(routes []string) Option
- func WithGroupedStatus(grouped bool) Option
- func WithPathAggregator(aggregator func(string, string, int) string) Option
- func WithRecordDuration(record bool) Option
- func WithRecordRequestSize(record bool) Option
- func WithRecordRequests(record bool) Option
- func WithRecordResponseSize(record bool) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMetricHandler ¶
func GetMetricHandler(opt ...HandlerOption) http.Handler
GetMetricHandler returns an HTTP handler for exposing Prometheus metrics collected by the prometheus/promhttp package.
func Middleware ¶
func Middleware(options ...Option) gin.HandlerFunc
Middleware returns a Gin middleware handler function for collecting and exporting Prometheus metrics. It supports optional configuration through variadic Option parameters.
Types ¶
type HandlerOption ¶
type HandlerOption func(*handlerConfig)
Option defines a function type used to modify the configuration of a service during initialization.
func WithBasicAuth ¶
func WithBasicAuth(username, password string) HandlerOption
type Option ¶
type Option func(*config)
Option defines a function type used to modify the configuration of a service during initialization.
func WithAggregateStatusCode ¶
WithAggregateStatusCode sets whether to aggregate request status codes in the configuration.
func WithFilterPath ¶
WithFilterPath sets a filter function to determine which paths should be included or excluded from certain operations.
func WithFilterRoutes ¶
WithFilterRoutes creates an Option to configure a filter that allows tracking only specified routes in the service.
func WithGroupedStatus ¶
WithGroupedStatus configures whether status codes should be grouped when collecting metrics.
func WithPathAggregator ¶
WithPathAggregator sets a custom path aggregator function to aggregate paths based on the provided arguments.
func WithRecordDuration ¶
WithRecordDuration sets whether to record the duration of operations in the configuration.
func WithRecordRequestSize ¶
WithRecordRequestSize enables or disables recording of request sizes in the configuration.
func WithRecordRequests ¶
WithRecordRequests configures whether to enable or disable recording of requests in the configuration.
func WithRecordResponseSize ¶
WithRecordResponseSize sets whether the response size should be recorded in the configuration.