Documentation
¶
Index ¶
Constants ¶
const (
ReplacePatternUID = `[a-zA-Z0-9-]{36}`
)
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(reg prometheus.Registerer)
Types ¶
type HttpRequestDoer ¶
func WithMetrics ¶
func WithMetrics(inner HttpRequestDoer, opts ...Option) HttpRequestDoer
WithMetrics wraps an HttpRequestDoer and records metrics for HTTP requests. clientName is added as a label to the metrics. pathReplacePattern is a regex pattern used to replace dynamic parts of the URL path in the metrics. e.g. `\/api\/v1\/users\/(?P<resourceId>.*)` will replace "/api/v1/users/123" with "/api/v1/users/resourceId". If no named groups are found, the original path will be used.
type Option ¶
type Option func(o *Options)
func WithClientName ¶
func WithReplaceFunc ¶
func WithReplaceFunc(replaceFunc ReplaceFunc) Option
func WithReplacePatterns ¶
type Options ¶
type Options struct {
ClientName string
PathReplacePattern string
ReplaceFunc ReplaceFunc
}
type ReplaceFunc ¶
func NewReplacePath ¶
func NewReplacePath(re *regexp.Regexp) ReplaceFunc
NewReplacePath replaces the named groups in the path with their corresponding names. If no named groups are found, the original path is returned. If the regex is nil, the original path is returned. The named groups are replaced with their names, and the rest of the path is preserved. For example, if the regex is `\/api\/v1\/users\/(?P<redacted>.*)` and the path is `/api/v1/users/123`, the result will be `/api/v1/users/redacted`.