@emartech/aggregate-metric-logger 2.0.2 → 2.0.5
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 +3 -3
- package/package.json +1 -1
- package/src/metric-logger.js +0 -5
- 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)
|
package/package.json
CHANGED
package/src/metric-logger.js
CHANGED
|
@@ -4,7 +4,6 @@ const loggerFactory = require('@emartech/json-logger');
|
|
|
4
4
|
const { getSeconds, startOfMinute, addSeconds } = require('date-fns');
|
|
5
5
|
const { omit, pick, fromPairs, toPairs } = require('lodash');
|
|
6
6
|
const stringify = require('json-stable-stringify');
|
|
7
|
-
const util = require('util');
|
|
8
7
|
|
|
9
8
|
module.exports = ({
|
|
10
9
|
enabled = true,
|
|
@@ -94,10 +93,6 @@ module.exports = ({
|
|
|
94
93
|
measure(tag, value, params = {}) {
|
|
95
94
|
addMeasurement({ tag, value, params });
|
|
96
95
|
},
|
|
97
|
-
count: util.deprecate(
|
|
98
|
-
(tag, value, params = {}) => addMeasurement({ tag, value, params }),
|
|
99
|
-
'count method is deprecated, use measure instead'
|
|
100
|
-
),
|
|
101
96
|
trace(tag, params = {}) {
|
|
102
97
|
addMeasurement({ method: 'trace', tag, params, value: 1, countOnly: true });
|
|
103
98
|
},
|
|
@@ -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', {
|