register_plumber_metrics: Metrics for Plumber APIs

Description Usage Arguments Value Examples

View source: R/plumber.R

Description

Automatically wrap a Plumber API app, adding metrics for HTTP request count and duration, and then expose them on a /metrics endpoint.

The endpoint will check the METRICS_HTTP_AUTHORIZATION environment variable, and if present will use it as the expected Authorization header of the request to the /metrics endpoint. This can be used to implement basic HTTP authentication for access to runtime metrics.

Usage

1

Arguments

app

A Plumber router object.

registry

A Registry object. See registry().

Value

A modified Plumber router.

Examples

1
2
3
4
5
6
7
8
if (requireNamespace("plumber", quietly = TRUE)) {
  app <- plumber::plumber$new() # Normally this is plumber::plumb().
  app <- register_plumber_metrics(app)
## Not run: 
  app$run()

## End(Not run)
}

atheriel/openmetrics documentation built on July 8, 2021, 3:34 a.m.