@emartech/aggregate-metric-logger 2.0.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +1 -1
- package/src/metric-logger.spec.js +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ aggregate metrics in memory and log them every minute
|
|
|
4
4
|
## Setup
|
|
5
5
|
|
|
6
6
|
Set `METRIC_LOGGER_ENABLED` env variable to `true` for aggregate-metric-logger to
|
|
7
|
-
start collecting and logging
|
|
7
|
+
start collecting and logging measurements.
|
|
8
8
|
|
|
9
9
|
To change the default `aggregate-metric-logger` namespace used for logs, set
|
|
10
10
|
`METRIC_LOGGER_NAMESPACE` to a custom value.
|
|
@@ -19,7 +19,7 @@ an extra `count` property to the logs and log them at the end of the minute with
|
|
|
19
19
|
`@emartech/json-logger`.
|
|
20
20
|
|
|
21
21
|
```js
|
|
22
|
-
const
|
|
22
|
+
const metricLogger = require('@emartech/aggregate-metric-logger')
|
|
23
23
|
|
|
24
24
|
metricLogger.warn('etwas-went-wrong', { customer_id: 11 });
|
|
25
25
|
metricLogger.warn('etwas-went-wrong', { customer_id: 11 });
|
|
@@ -33,7 +33,7 @@ If you want aggregate measurements about something you need to simply call the `
|
|
|
33
33
|
for each value:
|
|
34
34
|
|
|
35
35
|
```js
|
|
36
|
-
const
|
|
36
|
+
const metricLogger = require('@emartech/aggregate-metric-logger')
|
|
37
37
|
|
|
38
38
|
metricLogger.measure('thing-to-measure', 14)
|
|
39
39
|
metricLogger.measure('thing-to-measure', 20)
|
|
@@ -61,10 +61,10 @@ function exampleIOHeavyFunction() {
|
|
|
61
61
|
### Group by extra parameters
|
|
62
62
|
|
|
63
63
|
If you want to group by additional parameters inside a tag, you can pass down these extra
|
|
64
|
-
params in an object to `
|
|
64
|
+
params in an object to `measure` and `start` as the last optional argument:
|
|
65
65
|
|
|
66
66
|
```js
|
|
67
|
-
metricLogger.
|
|
67
|
+
metricLogger.measure('thing-to-count', 14, { customer_id: 12 });
|
|
68
68
|
|
|
69
69
|
const measurement = metricLogger.start(
|
|
70
70
|
'tag-for-the-measuement',
|
package/package.json
CHANGED
|
@@ -137,9 +137,9 @@ describe('metricLogger', () => {
|
|
|
137
137
|
|
|
138
138
|
describe('start/stop', () => {
|
|
139
139
|
it('should log min, max, count and sum when log was called only once', () => {
|
|
140
|
-
const
|
|
140
|
+
const measurement = metricLogger.start('utlegeles');
|
|
141
141
|
clock.tick(50);
|
|
142
|
-
metricLogger.stop(
|
|
142
|
+
metricLogger.stop(measurement);
|
|
143
143
|
|
|
144
144
|
clock.tick(60 * 1000);
|
|
145
145
|
expect(Logger.prototype.info).toBeCalledWith('utlegeles', {
|