(assoc-route-summary acc route-id route-timer)Inputs: [acc :- {RouteIdentifier RouteSummary} route-id :- RouteIdentifier route-timer :- Timer] Returns: {RouteIdentifier RouteSummary}
Add summary information for the given route-id to the accumulator map.
Inputs: [acc :- {RouteIdentifier RouteSummary} route-id :- RouteIdentifier route-timer :- Timer]
Returns: {RouteIdentifier RouteSummary}
Add summary information for the given route-id to the accumulator map.(find-http-route-timer route-id route-timers)Given a route-id and a map of timers, return the timer for the requested route,
or the catch-all :other timer if there is no timer for the route.
Given a route-id and a map of timers, return the timer for the requested route, or the catch-all `:other` timer if there is no timer for the route.
(initialize-http-metrics! registry hostname route-metadata)Inputs: [registry :- (schema/maybe MetricRegistry) hostname :- schema/Str route-metadata :- comidi/RouteMetadata] Returns: (schema/maybe HttpMetrics)
Initialize a MetricRegistry with metrics for a list of HTTP endpoints. The
registry will be populated with a num-cpus metric for the system, a Counter
and a Histogram for tracking active requests, and a Timer that will be used
to measure all requests. route-metadata is the comidi route metadata for
all of the routes that we want to track metrics for; for each of these, a Timer
will be initialized, as well as a Ratio that keeps track of the percentage of
total requests that were directed to the named endpoint. This function is
intended for use with the wrap-with-request-metrics Ring middleware from
this library, and the wrap-with-route-metadata Ring middleware from comidi.
Inputs: [registry :- (schema/maybe MetricRegistry) hostname :- schema/Str route-metadata :- comidi/RouteMetadata] Returns: (schema/maybe HttpMetrics) Initialize a MetricRegistry with metrics for a list of HTTP endpoints. The registry will be populated with a `num-cpus` metric for the system, a Counter and a Histogram for tracking active requests, and a Timer that will be used to measure all requests. `route-metadata` is the comidi route metadata for all of the routes that we want to track metrics for; for each of these, a Timer will be initialized, as well as a Ratio that keeps track of the percentage of total requests that were directed to the named endpoint. This function is intended for use with the `wrap-with-request-metrics` Ring middleware from this library, and the `wrap-with-route-metadata` Ring middleware from comidi.
(register-http-metrics registry total-requests metric-name-fn route-names)Inputs: [registry :- MetricRegistry total-requests :- Timer metric-name-fn :- (schema/pred ifn?) route-names :- [schema/Str]] Returns: TimersMap
Initialize metrics for a list of http endpoints.
Inputs: [registry :- MetricRegistry total-requests :- Timer metric-name-fn :- (schema/pred ifn?) route-names :- [schema/Str]] Returns: TimersMap Initialize metrics for a list of http endpoints.
(register-metrics-for-endpoint registry
total-requests
metric-name-fn
acc
endpoint)Inputs: [registry :- MetricRegistry total-requests :- Timer metric-name-fn :- (schema/pred ifn?) acc :- TimersMap endpoint :- schema/Str] Returns: TimersMap
Initialize metrics for an http endpoint and add them to the registry. This includes a Timer for the endpoint itself, and a Ratio to track the percentage of total requests that were directed to this endpoint.
Inputs: [registry :- MetricRegistry total-requests :- Timer metric-name-fn :- (schema/pred ifn?) acc :- TimersMap endpoint :- schema/Str] Returns: TimersMap Initialize metrics for an http endpoint and add them to the registry. This includes a Timer for the endpoint itself, and a Ratio to track the percentage of total requests that were directed to this endpoint.
(request-summary metrics)Inputs: [metrics :- HttpMetrics] Returns: RequestSummary
Build a summary of request data to all of the routes registered in the metrics.
Inputs: [metrics :- HttpMetrics] Returns: RequestSummary Build a summary of request data to all of the routes registered in the metrics.
(wrap-with-request-metrics app
{:keys [active-counter active-histo total-timer
route-timers]
:as http-metrics})Inputs: [app :- (schema/pred ifn?) {:keys [active-counter active-histo total-timer route-timers], :as http-metrics} :- (schema/maybe HttpMetrics)] Returns: (schema/pred ifn?)
Ring middleware. Wraps the given ring handler with code that will update the
various metrics created by a call to initialize-http-metrics!, based on whether
or not the request is directed to one of the endpoints that metrics are being
tracked for. The comidi route metadata (via the comidi wrap-with-route-metadata
Ring middleware) will be used to determine which metric should be associated with the request.
Inputs: [app :- (schema/pred ifn?) {:keys [active-counter active-histo total-timer route-timers], :as http-metrics} :- (schema/maybe HttpMetrics)]
Returns: (schema/pred ifn?)
Ring middleware. Wraps the given ring handler with code that will update the
various metrics created by a call to `initialize-http-metrics!`, based on whether
or not the request is directed to one of the endpoints that metrics are being
tracked for. The comidi route metadata (via the comidi `wrap-with-route-metadata`
Ring middleware) will be used to determine which metric should be associated with the request.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |