Allows an object for collecting and registering gauges, counters, etc
new()
CollectorRegistry$new(storage_adapter = NULL)
storage_adapter
instance of the storage adapter to how you want to persist metrics
instance of CollectorRegistry
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter Return the list of samples CollectorRegistry, typically to render after
getMetricFamilySamples()
CollectorRegistry$getMetricFamilySamples()
list of MetricFamilySamples
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter renderer <- PrometheusRenderMetrics$new() out <- renderer$render(registry$getMetricFamilySamples()) Registers a gauge to be leveraged later
registerGauge()
CollectorRegistry$registerGauge(name, help, namespace = NULL, labels = list())
name
name of the gauge
help
help text of the gauge
namespace
optional namespace that will be help keep the name unique
labels
list of label names to be used in the gauge
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter registry$registerGauge( name = 'test', help = 'some_gauge', namespace = "my_space" ) Retrieves the gauge to be leveraged
getGauge()
CollectorRegistry$getGauge(name, namespace = NULL)
name
name of the gauge
namespace
optional namespace that will be help keep the name unique
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter registry$registerGauge( name = 'test', help = 'my_gauge', namespace = "my_space" ) count <- registry$getGauge(name = 'my_gauge', namespace = "my_space") count$incBy(5) Registers a counter to be leveraged later
registerCounter()
CollectorRegistry$registerCounter( name, help, namespace = NULL, labels = list() )
name
name of the counter
help
help text of the counter
namespace
optional namespace that will be help keep the name unique
labels
list of label names to be used in the counter
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter registry$registerCounter( name = 'test', help = 'some_counter', namespace = "my_space" ) Retrieves the counter to be leveraged
getCounter()
CollectorRegistry$getCounter(name, namespace = NULL)
name
name of the counter
namespace
optional namespace that will be help keep the name unique
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter registry$registerCounter( name = 'test', help = 'my_counter', namespace = "my_space" ) count <- registry$getCounter(name = 'my_counter', namespace = "my_space") count$inc()
clone()
The objects of this class are cloneable with this method.
CollectorRegistry$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ## ------------------------------------------------
## Method `CollectorRegistry$new`
## ------------------------------------------------
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter
Return the list of samples CollectorRegistry, typically to render after
## ------------------------------------------------
## Method `CollectorRegistry$getMetricFamilySamples`
## ------------------------------------------------
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter
renderer <- PrometheusRenderMetrics$new()
out <- renderer$render(registry$getMetricFamilySamples())
Registers a gauge to be leveraged later
## ------------------------------------------------
## Method `CollectorRegistry$registerGauge`
## ------------------------------------------------
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter
registry$registerGauge( name = 'test', help = 'some_gauge', namespace = "my_space" )
Retrieves the gauge to be leveraged
## ------------------------------------------------
## Method `CollectorRegistry$getGauge`
## ------------------------------------------------
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter
registry$registerGauge( name = 'test', help = 'my_gauge', namespace = "my_space" )
count <- registry$getGauge(name = 'my_gauge', namespace = "my_space")
count$incBy(5)
Registers a counter to be leveraged later
## ------------------------------------------------
## Method `CollectorRegistry$registerCounter`
## ------------------------------------------------
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter
registry$registerCounter( name = 'test', help = 'some_counter', namespace = "my_space" )
Retrieves the counter to be leveraged
## ------------------------------------------------
## Method `CollectorRegistry$getCounter`
## ------------------------------------------------
registry <- CollectorRegistry$new() # default to a new PrometheusMemoryAdapter
registry$registerCounter( name = 'test', help = 'my_counter', namespace = "my_space" )
count <- registry$getCounter(name = 'my_counter', namespace = "my_space")
count$inc()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.