Documentation ¶
Overview ¶
SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func ProvideHandlerCounter(o prometheus.CounterOpts, l *ServerLabellers) fx.Annotated
- func ProvideHandlerDurationHistogram(o prometheus.HistogramOpts, l *ServerLabellers) fx.Annotated
- func ProvideHandlerDurationSummary(o prometheus.SummaryOpts, l *ServerLabellers) fx.Annotated
- func ProvideHandlerInFlight(o prometheus.GaugeOpts) fx.Annotated
- func ProvideRoundTripperCounter(o prometheus.CounterOpts, l *ClientLabellers) fx.Annotated
- func ProvideRoundTripperDurationHistogram(o prometheus.HistogramOpts, l *ClientLabellers) fx.Annotated
- func ProvideRoundTripperDurationSummary(o prometheus.SummaryOpts, l *ClientLabellers) fx.Annotated
- func ProvideRoundTripperInFlight(o prometheus.GaugeOpts) fx.Annotated
- func Unmarshal(configKey string, ho promhttp.HandlerOpts) func(xmetrics.MetricsIn) (MetricsHttpOut, error)
- type ClientLabeller
- type ClientLabellers
- type CodeLabeller
- type EmptyLabeller
- type Handler
- type HandlerCounter
- type HandlerDuration
- type HandlerInFlight
- type LabelNames
- type MethodLabeller
- type MetricsHttpOut
- type RoundTripperCounter
- type RoundTripperDuration
- type RoundTripperInFlight
- type ServerLabeller
- type ServerLabellers
- type StatusCoder
Constants ¶
const ( DefaultCodeLabel = "code" DefaultMethodLabel = "method" DefaultOther = "other" )
Variables ¶
This section is empty.
Functions ¶
func ProvideHandlerCounter ¶
func ProvideHandlerCounter(o prometheus.CounterOpts, l *ServerLabellers) fx.Annotated
func ProvideHandlerDurationHistogram ¶
func ProvideHandlerDurationHistogram(o prometheus.HistogramOpts, l *ServerLabellers) fx.Annotated
func ProvideHandlerDurationSummary ¶
func ProvideHandlerDurationSummary(o prometheus.SummaryOpts, l *ServerLabellers) fx.Annotated
func ProvideHandlerInFlight ¶
func ProvideHandlerInFlight(o prometheus.GaugeOpts) fx.Annotated
func ProvideRoundTripperCounter ¶
func ProvideRoundTripperCounter(o prometheus.CounterOpts, l *ClientLabellers) fx.Annotated
func ProvideRoundTripperDurationHistogram ¶
func ProvideRoundTripperDurationHistogram(o prometheus.HistogramOpts, l *ClientLabellers) fx.Annotated
func ProvideRoundTripperDurationSummary ¶
func ProvideRoundTripperDurationSummary(o prometheus.SummaryOpts, l *ClientLabellers) fx.Annotated
func ProvideRoundTripperInFlight ¶
func ProvideRoundTripperInFlight(o prometheus.GaugeOpts) fx.Annotated
func Unmarshal ¶
func Unmarshal(configKey string, ho promhttp.HandlerOpts) func(xmetrics.MetricsIn) (MetricsHttpOut, error)
Types ¶
type ClientLabeller ¶
type ClientLabeller interface { LabelNames // ClientLabels applies the labels this strategy provides. The order the labels are applies // must match the order of names returned by LabelNames. ClientLabels(*http.Response, *http.Request, *xmetrics.Labels) }
ClientLabeller is a strategy for producing metrics label/value pairs from a clientside HTTP request
type ClientLabellers ¶
type ClientLabellers struct {
// contains filtered or unexported fields
}
ClientLabellers is a set of ClientLabeller strategies to be executed in sequence. Keys are label names. This type guarantees a consistent ordering for both the labels and labellers.
A default ClientLabellers is ready to use and can be built up using Add. A nil ClientLabellers is valid and acts as a no-op.
func NewClientLabellers ¶
func NewClientLabellers(labellers ...ClientLabeller) *ClientLabellers
func (*ClientLabellers) ClientLabels ¶
func (*ClientLabellers) LabelNames ¶
func (cl *ClientLabellers) LabelNames() []string
LabelNames returns the label names in the order they were added. This is the same order that ClientLabels applies labels to a metric.
type CodeLabeller ¶
type CodeLabeller struct { // Name is the name of the label to apply. If unset, DefaultCodeLabel is used. Name string }
CodeLabeller provides both ServerLabeller and ClientLabeller functionality for HTTP response codes. For servers, the http.ResponseWriter must implement the StatusCode interface, or this labeller will panic.
func (CodeLabeller) ClientLabels ¶
func (CodeLabeller) LabelNames ¶
func (cl CodeLabeller) LabelNames() []string
func (CodeLabeller) ServerLabels ¶
func (cl CodeLabeller) ServerLabels(response http.ResponseWriter, _ *http.Request, l *xmetrics.Labels)
type EmptyLabeller ¶
type EmptyLabeller struct{}
EmptyLabeller is both a server and client labeller which produces no labels
func (EmptyLabeller) ClientLabels ¶
func (EmptyLabeller) LabelNames ¶
func (el EmptyLabeller) LabelNames() []string
func (EmptyLabeller) ServerLabels ¶
func (el EmptyLabeller) ServerLabels(http.ResponseWriter, *http.Request, *xmetrics.Labels)
type Handler ¶
func NewHandler ¶
func NewHandler(g prometheus.Gatherer, o promhttp.HandlerOpts) Handler
type HandlerCounter ¶
type HandlerCounter struct { Metric xmetrics.Adder Labeller ServerLabeller }
HandlerCounter provides a simple count metric of HTTP transactions
type HandlerDuration ¶
type HandlerDuration struct { Metric xmetrics.Observer Labeller ServerLabeller // Now is the optional strategy for obtaining the system time. If not supplied, time.Now is used. Now func() time.Time // Units is the time unit to report the metric in. If unset, time.Millisecond is used. Any of the // time duration constants can be used here, e.g. time.Second or time.Minute. Units time.Duration }
HandlerDuration provides request duration metrics
type HandlerInFlight ¶
type HandlerInFlight struct {
Metric xmetrics.GaugeAdder
}
HandlerInFlight records how many current HTTP transactions are being executed by an http.Handler
type LabelNames ¶
type LabelNames interface { // LabelNames returns the ordered set of metrics label names. The order in which these // names occur in the slice will match any labeller strategies in a ClientLabeller or a ServerLabeller. LabelNames() []string }
LabelNames is a strategy for determining the names for metrics labels
type MethodLabeller ¶
type MethodLabeller struct { // Name is the name of the label to apply. If unset, DefaultMethodLabel is used. Name string // TrackedMethods is a set of HTTP methods that are tracked by this labeller. Methods that // don't have keys in this map use the Other value instead. If unset, a default map // is used that includes all standard HTTP methods. TrackedMethods map[string]bool // Other is the value used for methods that do not have a key in the TrackedMethods map. // If unset, DefaultOther is used. Other string }
MethodLabeller provides both server and client labeling for the HTTP request method.
func (MethodLabeller) ClientLabels ¶
func (MethodLabeller) LabelNames ¶
func (ml MethodLabeller) LabelNames() []string
func (MethodLabeller) ServerLabels ¶
func (ml MethodLabeller) ServerLabels(_ http.ResponseWriter, request *http.Request, l *xmetrics.Labels)
type MetricsHttpOut ¶
type MetricsHttpOut struct { xmetrics.MetricsOut Handler Handler }
type RoundTripperCounter ¶
type RoundTripperCounter struct { Metric xmetrics.Adder Labeller ClientLabeller }
RoundTripperCounter provides a simple counting metric for clients executing HTTP transactions
func (RoundTripperCounter) Then ¶
func (irtc RoundTripperCounter) Then(next http.RoundTripper) http.RoundTripper
type RoundTripperDuration ¶
type RoundTripperDuration struct { Metric xmetrics.Observer Labeller ClientLabeller // Now is the optional strategy for obtaining the system time. If not supplied, time.Now is used. Now func() time.Time // Units is the time unit to report the metric in. If unset, time.Millisecond is used. Any of the // time duration constants can be used here, e.g. time.Second or time.Minute. Units time.Duration }
func (RoundTripperDuration) Then ¶
func (irtd RoundTripperDuration) Then(next http.RoundTripper) http.RoundTripper
type RoundTripperInFlight ¶
type RoundTripperInFlight struct {
Metric xmetrics.GaugeAdder
}
HandlerInFlight provides a gauge of how many in-flight HTTP transactions a client has initiated. No labeller is used here, as the reporter must be invoked before the transaction executes to produce a response.
func (RoundTripperInFlight) Then ¶
func (irtif RoundTripperInFlight) Then(next http.RoundTripper) http.RoundTripper
type ServerLabeller ¶
type ServerLabeller interface { LabelNames // ServerLabels applies the labels this strategy provides. The order the labels are applies // must match the order of names returned by LabelNames. ServerLabels(http.ResponseWriter, *http.Request, *xmetrics.Labels) }
ServerLabeller is a strategy for producing metrics label/value pairs from a serverside HTTP request
type ServerLabellers ¶
type ServerLabellers struct {
// contains filtered or unexported fields
}
ServerLabellers is a set of ServerLabeller strategies to be executed in sequence. Keys are label names. This type guarantees a consistent ordering for both the labels and labellers.
A default ServerLabellers is ready to use and can be built up using Add. A nil ServerLabellers is also valid, and acts as a no-op.
func NewServerLabellers ¶
func NewServerLabellers(labellers ...ServerLabeller) *ServerLabellers
func (*ServerLabellers) LabelNames ¶
func (sl *ServerLabellers) LabelNames() []string
func (*ServerLabellers) ServerLabels ¶
func (sl *ServerLabellers) ServerLabels(response http.ResponseWriter, request *http.Request, l *xmetrics.Labels)
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
StatusCoder is expected to be implemented by http.ResponseWriters that participate in metrics. Decorating the http.ResponseWriter is left to other packages.