Documentation ¶
Index ¶
- Constants
- Variables
- func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) fasthttp.RequestHandler
- func InstrumentHandlerInFlight(g prometheus.Gauge, next fasthttp.RequestHandler) fasthttp.RequestHandler
- func InstrumentMetricHandler(reg prometheus.Registerer, handler fasthttp.RequestHandler) fasthttp.RequestHandler
- func ParseFormat(acceptHeader string, enableOpenMetrics bool) expfmt.Format
- func PrometheusHandler(opts HandlerOpts) fasthttp.RequestHandler
- func PrometheusHandlerFor(opts HandlerOpts, next fasthttp.RequestHandler) fasthttp.RequestHandler
- func RequestCounterHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
- type HandlerErrorHandling
- type HandlerOpts
- type Logger
Constants ¶
View Source
const ( REQUEST_OTHER = "Other" REQUEST_ALL = "All" )
Variables ¶
View Source
var Request_Metrics_Codes = map[string]int{ strconv.Itoa(http.StatusOK): 1, strconv.Itoa(http.StatusFound): 1, strconv.Itoa(http.StatusNotModified): 1, strconv.Itoa(http.StatusUseProxy): 1, strconv.Itoa(http.StatusSeeOther): 1, strconv.Itoa(http.StatusTemporaryRedirect): 1, strconv.Itoa(http.StatusPermanentRedirect): 1, strconv.Itoa(http.StatusBadRequest): 1, strconv.Itoa(http.StatusUnauthorized): 1, strconv.Itoa(http.StatusMethodNotAllowed): 1, strconv.Itoa(http.StatusForbidden): 1, strconv.Itoa(http.StatusNotFound): 1, strconv.Itoa(http.StatusInternalServerError): 1, strconv.Itoa(http.StatusNotImplemented): 1, strconv.Itoa(http.StatusBadGateway): 1, strconv.Itoa(http.StatusServiceUnavailable): 1, strconv.Itoa(http.StatusGatewayTimeout): 1, strconv.Itoa(http.StatusHTTPVersionNotSupported): 1, }
Functions ¶
func HandlerFor ¶
func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) fasthttp.RequestHandler
func InstrumentHandlerInFlight ¶
func InstrumentHandlerInFlight(g prometheus.Gauge, next fasthttp.RequestHandler) fasthttp.RequestHandler
func InstrumentMetricHandler ¶
func InstrumentMetricHandler(reg prometheus.Registerer, handler fasthttp.RequestHandler) fasthttp.RequestHandler
func PrometheusHandler ¶
func PrometheusHandler(opts HandlerOpts) fasthttp.RequestHandler
func PrometheusHandlerFor ¶ added in v1.0.2
func PrometheusHandlerFor(opts HandlerOpts, next fasthttp.RequestHandler) fasthttp.RequestHandler
func RequestCounterHandler ¶
func RequestCounterHandler(next fasthttp.RequestHandler) fasthttp.RequestHandler
Types ¶
type HandlerErrorHandling ¶
type HandlerErrorHandling int
HandlerErrorHandling defines how a Handler serving metrics will handle errors.
const ( HTTPErrorOnError HandlerErrorHandling = iota ContinueOnError PanicOnError )
These constants cause handlers serving metrics to behave as described if errors are encountered.
type HandlerOpts ¶
type HandlerOpts struct { // ErrorLog specifies an optional Logger for errors collecting and // serving metrics. If nil, errors are not logged at all. Note that the // type of a reported error is often prometheus.MultiError, which // formats into a multi-line error string. If you want to avoid the // latter, create a Logger implementation that detects a // prometheus.MultiError and formats the contained errors into one line. ErrorLog Logger // ErrorHandling defines how errors are handled. Note that errors are // logged regardless of the configured ErrorHandling provided ErrorLog // is not nil. ErrorHandling HandlerErrorHandling // If Registry is not nil, it is used to register a metric // "promhttp_metric_handler_errors_total", partitioned by "cause". A // failed registration causes a panic. Note that this error counter is // different from the instrumentation you get from the various // InstrumentHandler... helpers. It counts errors that don't necessarily // result in a non-2xx HTTP status code. There are two typical cases: // (1) Encoding errors that only happen after streaming of the HTTP body // has already started (and the status code 200 has been sent). This // should only happen with custom collectors. (2) Collection errors with // no effect on the HTTP status code because ErrorHandling is set to // ContinueOnError. Registry prometheus.Registerer // If DisableCompression is true, the handler will never compress the // response, even if requested by the client. DisableCompression bool // The number of concurrent HTTP requests is limited to // MaxRequestsInFlight. Additional requests are responded to with 503 // Service Unavailable and a suitable message in the body. If // MaxRequestsInFlight is 0 or negative, no limit is applied. MaxRequestsInFlight int // If handling a request takes longer than Timeout, it is responded to // with 503 ServiceUnavailable and a suitable Message. No timeout is // applied if Timeout is 0 or negative. Note that with the current // implementation, reaching the timeout simply ends the HTTP requests as // described above (and even that only if sending of the body hasn't // started yet), while the bulk work of gathering all the metrics keeps // running in the background (with the eventual result to be thrown // away). Until the implementation is improved, it is recommended to // implement a separate timeout in potentially slow Collectors. Timeout time.Duration // If true, the experimental OpenMetrics encoding is added to the // possible options during content negotiation. Note that Prometheus // 2.5.0+ will negotiate OpenMetrics as first priority. OpenMetrics is // the only way to transmit exemplars. However, the move to OpenMetrics // is not completely transparent. Most notably, the values of "quantile" // labels of Summaries and "le" labels of Histograms are formatted with // a trailing ".0" if they would otherwise look like integer numbers // (which changes the identity of the resulting series on the Prometheus // server). EnableOpenMetrics bool }
HandlerOpts specifies options how to serve metrics via an http.Handler. The zero value of HandlerOpts is a reasonable default.
Click to show internal directories.
Click to hide internal directories.