health

health(req: any, res: any)
Parameters
req (any)
res (any)

stats

Used when the exhaustive values of a label is not clear e.g. When it is stats for errorCodes.

stats(labelName: string): object
Parameters
labelName (string) The name of the label.
Returns
object: { [labelValue] : count}.

add

Add a new metrics unit from metrics-specs.

add
Parameters
options (object) Config.
Name Description
options.type string Type of the metrics, e.g. Counter.
options.name string Name of the metrics, e.g. Action_error.
options.specs object Other specific configuration for the metrics, e.g. Help, labelNames, buckets.

load

Load a list of metrics specs to metricsUnits.

load
Parameters
list (Array) List of metrics specs.

list

List the metrics unit instances stored in metricsUnits.

list
Returns
object: <{ [metrics name] : metrics unit instance}>.

find

Find a metrics unit by action/type or by name(higher priority).

find
Parameters
options (object) Config.
Name Description
options.action string Name of the action function.
options.type string Type of metrics attached to the action function.
options.name string Name of the metrics unit.
Returns
object: The metrics unit instance.

reset

Clear instances stored in metricsUnits and prometheus.register.

reset

objectContains

Check if object a contains another object b by shallow equal.

objectContains
Parameters
a (object) The bigger object.
b (object) The smaller object.
Returns
boolean: If contains.

objectOnlyKeys

Trim object keys to the target array.

objectOnlyKeys
Parameters
input (object) The object to be trimmed.
target (Array) The array of target keys.
Returns
object: The new object with trimmed keys.