new Collection( [name])
Creates a named collection of metrics
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
name |
string |
<optional> |
The name to use for this collection. |
- Source:
Example
var { Collection } = require('measured');
const collection = new Collection('node-process-metrics');
const gauge = collection.gauge('node.process.heap_used', () => {
return process.memoryUsage().heapUsed;
});
Methods
-
cachedGauge(name, valueProducingPromiseCallback, updateIntervalInSeconds)
-
Gets or creates and registers a SettableGauge
Parameters:
Name Type Description namestring The metric name
valueProducingPromiseCallbackfunction A function that returns a promise than when
resolved supplies the value that should be cached in this gauge.updateIntervalInSecondsnumber How often the cached gauge should update it's value.
- Source:
Returns:
- Type
- CachedGauge
-
counter(name [, properties])
-
Gets or creates and registers a Counter
Parameters:
Name Type Argument Description namestring The metric name
propertiesCounterProperties <optional>
- Source:
Returns:
- Type
- Counter
-
end()
-
Calls end on all metrics in the registry that support end()
- Source:
-
gauge(name, readFn)
-
Gets or creates and registers a Gauge
Parameters:
Name Type Description namestring The metric name
readFnfunction See Gauge
- Source:
Returns:
- Type
- Gauge
-
histogram(name [, properties])
-
Gets or creates and registers a Histogram
Parameters:
Name Type Argument Description namestring The metric name
propertiesHistogramProperties <optional>
- Source:
Returns:
- Type
- Histogram
-
meter(name [, properties])
-
Gets or creates and registers a Meter
Parameters:
Name Type Argument Description namestring The metric name
propertiesMeterProperties <optional>
See MeterProperties
- Source:
Returns:
- Type
- Meter
-
register(name, metric)
-
register a metric that was created outside the provided convenience methods of this collection
Parameters:
Name Type Description nameThe metric name
metricThe Metric implementation
- Source:
Example
var { Collection, Gauge } = require('measured'); const collection = new Collection('node-process-metrics'); const gauge = new Gauge(() => { return process.memoryUsage().heapUsed; }); collection.register('node.process.heap_used', gauge); -
settableGauge(name [, properties])
-
Gets or creates and registers a SettableGauge
Parameters:
Name Type Argument Description namestring The metric name
propertiesSettableGaugeProperties <optional>
- Source:
Returns:
- Type
- SettableGauge
-
timer(name [, properties])
-
Gets or creates and registers a Timer
Parameters:
Name Type Argument Description namestring The metric name
propertiesTimerProperties <optional>
See TimerProperties
- Source:
Returns:
- Type
- Timer
-
toJSON()
-
Fetches the data/values from all registered metrics
- Source:
Returns:
The combined JSON object
- Type
- Object
Measured