@@ -21,14 +21,14 @@ describe('AwsCloudWatchOtlpBatchLogRecordProcessor', () => {
2121 const nestedDictLog = generateTestLogData ( logBody , logKey , logDepth , 1 , true ) [ 0 ] ;
2222 const nestedArrayLog = generateTestLogData ( logBody , logKey , logDepth , 1 , false ) [ 0 ] ;
2323
24- const expectedDictSize = logKey . length * logDepth + logBody . length ;
25- const expectedArraySize = logBody . length ;
24+ const expectedDictSize = logKey . length * logDepth + logBody . length + BASE_LOG_BUFFER_BYTE_SIZE ;
25+ const expectedArraySize = logBody . length + BASE_LOG_BUFFER_BYTE_SIZE ;
2626
2727 const dictSize = ( AwsCloudWatchOtlpBatchLogRecordProcessor as any ) . estimateLogSize ( nestedDictLog , logDepth ) ;
2828 const arraySize = ( AwsCloudWatchOtlpBatchLogRecordProcessor as any ) . estimateLogSize ( nestedArrayLog , logDepth ) ;
2929
30- expect ( dictSize - BASE_LOG_BUFFER_BYTE_SIZE ) . toBe ( expectedDictSize ) ;
31- expect ( arraySize - BASE_LOG_BUFFER_BYTE_SIZE ) . toBe ( expectedArraySize ) ;
30+ expect ( dictSize ) . toBe ( expectedDictSize ) ;
31+ expect ( arraySize ) . toBe ( expectedArraySize ) ;
3232 } ) ;
3333
3434 it ( 'should handle both body and attributes' , ( ) => {
@@ -44,26 +44,29 @@ describe('AwsCloudWatchOtlpBatchLogRecordProcessor', () => {
4444 attributes : { [ attrKey ] : attrValue } ,
4545 } ;
4646
47- const expectedSize = logBody . length + attrKey . length + attrValue . length ;
47+ const expectedSize = logBody . length + attrKey . length + attrValue . length + BASE_LOG_BUFFER_BYTE_SIZE ;
4848 const actualSize = ( AwsCloudWatchOtlpBatchLogRecordProcessor as any ) . estimateLogSize ( record ) ;
4949
50- expect ( actualSize - BASE_LOG_BUFFER_BYTE_SIZE ) . toBe ( expectedSize ) ;
50+ expect ( actualSize ) . toBe ( expectedSize ) ;
5151 } ) ;
5252
5353 it ( 'should cut off calculation for nested structure that exceeds depth limit' , ( ) => {
5454 const maxDepth = 0 ;
5555 const calculatedBody = 'X' . repeat ( 400 ) ;
5656 const logBody = {
5757 calculated : 'X' . repeat ( 400 ) ,
58- restOfThisLogWillBeTruncated : {
58+ thisDataWillNotBeIncludedInSizeCalculation : {
5959 truncated : {
6060 test : 'X' . repeat ( MAX_LOG_REQUEST_BYTE_SIZE ) ,
6161 } ,
6262 } ,
6363 } ;
6464
6565 const expectedSize =
66- BASE_LOG_BUFFER_BYTE_SIZE + 'calculated' . length + calculatedBody . length + 'restOfThisLogWillBeTruncated' . length ;
66+ BASE_LOG_BUFFER_BYTE_SIZE +
67+ 'calculated' . length +
68+ calculatedBody . length +
69+ 'thisDataWillNotBeIncludedInSizeCalculation' . length ;
6770
6871 const testLogs = generateTestLogData ( logBody , 'key' , 0 , 1 , true ) ;
6972 const dictSize = ( AwsCloudWatchOtlpBatchLogRecordProcessor as any ) . estimateLogSize ( testLogs [ 0 ] , maxDepth ) ;
0 commit comments