@@ -12,7 +12,6 @@ import { Metrics, MetricUnits, MetricResolution } from '../../src/';
12
12
const MAX_METRICS_SIZE = 100 ;
13
13
const MAX_DIMENSION_COUNT = 29 ;
14
14
const DEFAULT_NAMESPACE = 'default_namespace' ;
15
- const DEFAULT_METRIC_RESOLUTION = MetricResolution . Standard ;
16
15
17
16
const consoleSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
18
17
@@ -556,8 +555,8 @@ describe('Class: Metrics', () => {
556
555
const serializedMetrics = metrics . serializeMetrics ( ) ;
557
556
558
557
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics ) . toStrictEqual ( [
559
- { Name : 'test_name' , Unit : 'Count' , StorageResolution : DEFAULT_METRIC_RESOLUTION } ,
560
- { Name : 'test_name2' , Unit : 'Count' , StorageResolution : DEFAULT_METRIC_RESOLUTION } ,
558
+ { Name : 'test_name' , Unit : 'Count' } ,
559
+ { Name : 'test_name2' , Unit : 'Count' } ,
561
560
] ) ;
562
561
563
562
expect ( serializedMetrics [ 'test_name' ] ) . toBe ( 1 ) ;
@@ -566,57 +565,53 @@ describe('Class: Metrics', () => {
566
565
} ) ;
567
566
568
567
describe ( 'Feature: Resolution of Metrics' , ( ) => {
569
- test ( 'Should use default metric resolution `Standard, 60` if none is set' , ( ) => {
568
+ test ( 'Should serialized metrics in EMF format not contain StorageResolution as key if none is set' , ( ) => {
570
569
const metrics = new Metrics ( ) ;
571
570
metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 ) ;
572
571
const serializedMetrics = metrics . serializeMetrics ( ) ;
573
572
574
- expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( DEFAULT_METRIC_RESOLUTION ) ;
575
- expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( MetricResolution . Standard ) ;
576
- expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( 60 ) ;
573
+ expect ( Object . keys ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] ) ) . not . toContain ( 'StorageResolution' ) ;
574
+ expect ( Object . keys ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] ) ) . toContain ( 'Name' ) ;
575
+ expect ( Object . keys ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] ) ) . toContain ( 'Unit' ) ;
577
576
578
577
} ) ;
579
578
580
- test ( 'Should use metric resolution `Standard, 60` if `Standard` is set' , ( ) => {
579
+ test ( 'Should be StorageResolution 60 if MetricResolution is set to `Standard` ' , ( ) => {
581
580
const metrics = new Metrics ( ) ;
582
581
metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 , MetricResolution . Standard ) ;
583
582
const serializedMetrics = metrics . serializeMetrics ( ) ;
584
583
585
584
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( MetricResolution . Standard ) ;
586
585
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( 60 ) ;
587
-
588
586
} ) ;
589
587
590
- test ( 'Should use metric resolution `Standard, 60` if `60` is set' , ( ) => {
588
+ test ( 'Should be StorageResolution 60 if MetricResolution is set to `60` ' , ( ) => {
591
589
const metrics = new Metrics ( ) ;
592
590
metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 , 60 ) ;
593
591
const serializedMetrics = metrics . serializeMetrics ( ) ;
594
592
595
593
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( MetricResolution . Standard ) ;
596
594
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( 60 ) ;
597
-
598
595
} ) ;
599
596
600
- test ( 'Should use metric resolution `High, 1` if `1` is set' , ( ) => {
597
+ test ( 'Should be StorageResolution 1 if MetricResolution is set to `High` ' , ( ) => {
601
598
const metrics = new Metrics ( ) ;
602
- metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 , 1 ) ;
599
+ metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 , MetricResolution . High ) ;
603
600
const serializedMetrics = metrics . serializeMetrics ( ) ;
604
601
605
602
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( MetricResolution . High ) ;
606
603
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( 1 ) ;
607
-
608
604
} ) ;
609
605
610
- test ( 'Should use metric resolution `High, 1` if `High` is set' , ( ) => {
606
+ test ( 'Should be StorageResolution 1 if MetricResolution is set to `1` ' , ( ) => {
611
607
const metrics = new Metrics ( ) ;
612
- metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 , MetricResolution . High ) ;
608
+ metrics . addMetric ( 'test_name' , MetricUnits . Seconds , 10 , 1 ) ;
613
609
const serializedMetrics = metrics . serializeMetrics ( ) ;
614
610
615
611
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( MetricResolution . High ) ;
616
612
expect ( serializedMetrics . _aws . CloudWatchMetrics [ 0 ] . Metrics [ 0 ] . StorageResolution ) . toBe ( 1 ) ;
617
613
618
614
} ) ;
619
-
620
615
} ) ;
621
616
622
617
describe ( 'Feature: Clearing Metrics ' , ( ) => {
0 commit comments