@@ -10,6 +10,8 @@ import { EnvironmentVariablesService } from '../../src/config/EnvironmentVariabl
1010import {
1111 COLD_START_METRIC ,
1212 DEFAULT_NAMESPACE ,
13+ EMF_MAX_TIMESTAMP_FUTURE_AGE ,
14+ EMF_MAX_TIMESTAMP_PAST_AGE ,
1315 MAX_DIMENSION_COUNT ,
1416 MAX_METRICS_SIZE ,
1517 MAX_METRIC_VALUES_SIZE ,
@@ -2269,9 +2271,6 @@ describe('Class: Metrics', () => {
22692271
22702272 for ( const { format, getTimestamp } of testCases ) {
22712273 describe ( `when timestamp is provided as ${ format } ` , ( ) => {
2272- const twoHours = 2 * 60 * 60 * 1000 ;
2273- const fourteenDays = 14 * 24 * 60 * 60 * 1000 ;
2274-
22752274 test ( 'should set the timestamp if provided in the future' , ( ) => {
22762275 // Prepare
22772276 const testMetric = 'test-metric' ;
@@ -2314,10 +2313,10 @@ describe('Class: Metrics', () => {
23142313 ) ;
23152314 } ) ;
23162315
2317- test ( 'should not log a warning if the timestamp exact two hours in the future and set the timestamp ' , ( ) => {
2316+ test ( 'should not log a warning if the timestamp is withing valid future range ' , ( ) => {
23182317 // Prepare
23192318 const testMetric = 'test-metric' ;
2320- const timestampMs = mockDate . getTime ( ) + twoHours ;
2319+ const timestampMs = mockDate . getTime ( ) + EMF_MAX_TIMESTAMP_FUTURE_AGE ;
23212320 const customLogger = {
23222321 warn : jest . fn ( ) ,
23232322 debug : jest . fn ( ) ,
@@ -2343,10 +2342,11 @@ describe('Class: Metrics', () => {
23432342 ) ;
23442343 } ) ;
23452344
2346- test ( 'should log a warning if the timestamp is more than two hours in the future but still set the timestamp' , ( ) => {
2345+ test ( 'should log a warning if the timestamp is more than the future range but still set the timestamp' , ( ) => {
23472346 // Prepare
23482347 const testMetric = 'test-metric' ;
2349- const timestampMs = mockDate . getTime ( ) + twoHours + 1 ;
2348+ const timestampMs =
2349+ mockDate . getTime ( ) + EMF_MAX_TIMESTAMP_FUTURE_AGE + 1 ;
23502350 const customLogger = {
23512351 warn : jest . fn ( ) ,
23522352 debug : jest . fn ( ) ,
@@ -2375,10 +2375,10 @@ describe('Class: Metrics', () => {
23752375 ) ;
23762376 } ) ;
23772377
2378- test ( 'should not log a warning if the timestamp is exact 14 days in the past and set the timestamp' , ( ) => {
2378+ test ( 'should not log a warning if the timestamp is within past range and set the timestamp' , ( ) => {
23792379 // Prepare
23802380 const testMetric = 'test-metric' ;
2381- const timestampMs = mockDate . getTime ( ) - fourteenDays ;
2381+ const timestampMs = mockDate . getTime ( ) - EMF_MAX_TIMESTAMP_PAST_AGE ;
23822382 const customLogger = {
23832383 warn : jest . fn ( ) ,
23842384 debug : jest . fn ( ) ,
@@ -2404,10 +2404,11 @@ describe('Class: Metrics', () => {
24042404 ) ;
24052405 } ) ;
24062406
2407- test ( 'should log a warning if the timestamp is more than 14 days in the past but still set the timestamp' , ( ) => {
2407+ test ( 'should log a warning if the timestamp is more than past range but still set the timestamp' , ( ) => {
24082408 // Prepare
24092409 const testMetric = 'test-metric' ;
2410- const timestampMs = mockDate . getTime ( ) - fourteenDays - 1 ;
2410+ const timestampMs =
2411+ mockDate . getTime ( ) - EMF_MAX_TIMESTAMP_PAST_AGE - 1 ;
24112412 const customLogger = {
24122413 warn : jest . fn ( ) ,
24132414 debug : jest . fn ( ) ,
0 commit comments