@emartech/aggregate-metric-logger 6.7.2 → 6.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emartech/aggregate-metric-logger",
3
- "version": "6.7.2",
3
+ "version": "6.7.4",
4
4
  "description": "aggregate metrics in memory for logging",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -551,10 +551,31 @@ describe('gcpMetricCollector', () => {
551
551
  gcpMetricCollector.count('jolo', {}, 1);
552
552
  jest.advanceTimersByTime(60 * 1000 + 1);
553
553
 
554
+ expect(MetricServiceClient.prototype.createTimeSeries).toHaveBeenCalledTimes(1);
555
+
554
556
  firstCreateTimeSeriesPromise.resolve();
555
557
  await flushPromises();
558
+ });
556
559
 
557
- expect(MetricServiceClient.prototype.createTimeSeries).toHaveBeenCalledTimes(1);
560
+ it('should publish the second count after the first flush resolves', async () => {
561
+ const firstCreateTimeSeriesPromise = resolvablePromise();
562
+ jest.spyOn(MetricServiceClient.prototype, 'createTimeSeries')
563
+ .mockReturnValueOnce(firstCreateTimeSeriesPromise)
564
+ .mockResolvedValue();
565
+
566
+ gcpMetricCollector.count('jolo', {}, 1);
567
+ jest.advanceTimersByTime(60 * 1000 + 1);
568
+
569
+ gcpMetricCollector.count('jolo', {}, 1);
570
+ jest.advanceTimersByTime(60 * 1000 + 1);
571
+
572
+ firstCreateTimeSeriesPromise.resolve();
573
+ await flushPromises();
574
+
575
+ jest.advanceTimersByTime(60 * 1000 + 1);
576
+ await flushPromises();
577
+
578
+ expect(MetricServiceClient.prototype.createTimeSeries).toHaveBeenCalledTimes(2);
558
579
  });
559
580
  });
560
581
 
@@ -17,7 +17,7 @@ class GcpTimeSeriesBuilder {
17
17
  return {
18
18
  metric: {
19
19
  type: `custom.googleapis.com/${metric.name}`,
20
- labels: { ...metric.labels }
20
+ labels: { ...metric.labels, hostname: process.env.HOSTNAME }
21
21
  },
22
22
  resource: {
23
23
  type: 'global',
@@ -37,7 +37,8 @@ describe('gcpTimeSeriesBuilder', () => {
37
37
  {
38
38
  metric: {
39
39
  labels: {
40
- a: 1
40
+ a: 1,
41
+ hostname: 'local-machine'
41
42
  },
42
43
  type: 'custom.googleapis.com/kacs'
43
44
  },