PrometheusSample: Prometheus Sample R6 Object

Description Methods Examples

Description

Classic data object to encapsulate a sampling of a metric. You likely will not interact witht this object

Methods

Public methods


Method new()

Usage
PrometheusSample$new(name, value, label_names = list(), label_values = list())
Arguments
name

name of the sample, combined in other functions or R6 objects with namespace

value

the actual value of the sample

label_names

the name of the labels being passed in

label_values

the actual values of the labels. This must be UTF-8 encoded and the same number of labels

Returns

instance of PrometheusSample

Examples
sample <- PrometheusSample$new("sample name", 10)
Getter for the sample name


Method getName()

Usage
PrometheusSample$getName()
Returns

fully qualified name of the sample

Examples
sample <- PrometheusSample$new("sample name", 10)
print(sample$getName()) # 'sample name'
Getter for the label names


Method getLabelNames()

Usage
PrometheusSample$getLabelNames()
Returns

list of label names in the sample Getter for the label values


Method getLabelValues()

Usage
PrometheusSample$getLabelValues()
Returns

list of label values in the sample Getter for the sample value


Method getValue()

Usage
PrometheusSample$getValue()
Returns

list of sample values in the sample Setter for the sample value


Method setValue()

Usage
PrometheusSample$setValue(val)
Arguments
val

value to actually set

Returns

self Helper function to check if this sample has labels by checking label names


Method hasLabelNames()

Usage
PrometheusSample$hasLabelNames()
Returns

bool if sample has label_names

Examples
sample <- PrometheusSample$new("sample name", 10, list("colors"), list("red"))
sample$hasLabelNames() # TRUE

Method clone()

The objects of this class are cloneable with this method.

Usage
PrometheusSample$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## ------------------------------------------------
## Method `PrometheusSample$new`
## ------------------------------------------------

sample <- PrometheusSample$new("sample name", 10)
Getter for the sample name


## ------------------------------------------------
## Method `PrometheusSample$getName`
## ------------------------------------------------

sample <- PrometheusSample$new("sample name", 10)
print(sample$getName()) # 'sample name'
Getter for the label names


## ------------------------------------------------
## Method `PrometheusSample$hasLabelNames`
## ------------------------------------------------

sample <- PrometheusSample$new("sample name", 10, list("colors"), list("red"))
sample$hasLabelNames() # TRUE

cfmack/pRometheus documentation built on Jan. 25, 2021, 3:45 a.m.