@@ -3,6 +3,10 @@ import { CounterMetric } from '../../../src/metrics/instance';
3
3
import { serializeMetricBuckets } from '../../../src/metrics/utils' ;
4
4
import { TestClient , getDefaultTestClientOptions } from '../../mocks/client' ;
5
5
6
+ function _cleanupAggregator ( aggregator : BrowserMetricsAggregator ) : void {
7
+ clearInterval ( aggregator [ '_interval' ] ) ;
8
+ }
9
+
6
10
describe ( 'BrowserMetricsAggregator' , ( ) => {
7
11
const options = getDefaultTestClientOptions ( { tracesSampleRate : 0.0 } ) ;
8
12
const testClient = new TestClient ( options ) ;
@@ -21,6 +25,8 @@ describe('BrowserMetricsAggregator', () => {
21
25
timestamp : expect . any ( Number ) ,
22
26
unit : 'none' ,
23
27
} ) ;
28
+
29
+ _cleanupAggregator ( aggregator ) ;
24
30
} ) ;
25
31
26
32
it ( 'groups same items together' , ( ) => {
@@ -40,6 +46,8 @@ describe('BrowserMetricsAggregator', () => {
40
46
unit : 'none' ,
41
47
} ) ;
42
48
expect ( firstValue . metric . _value ) . toEqual ( 2 ) ;
49
+
50
+ _cleanupAggregator ( aggregator ) ;
43
51
} ) ;
44
52
45
53
it ( 'differentiates based on tag value' , ( ) => {
@@ -48,6 +56,8 @@ describe('BrowserMetricsAggregator', () => {
48
56
expect ( aggregator [ '_buckets' ] . size ) . toEqual ( 1 ) ;
49
57
aggregator . add ( 'g' , 'cpu' , 55 , undefined , { a : 'value' } ) ;
50
58
expect ( aggregator [ '_buckets' ] . size ) . toEqual ( 2 ) ;
59
+
60
+ _cleanupAggregator ( aggregator ) ;
51
61
} ) ;
52
62
53
63
describe ( 'serializeBuckets' , ( ) => {
@@ -69,6 +79,8 @@ describe('BrowserMetricsAggregator', () => {
69
79
expect ( serializedBuckets ) . toContain ( 'cpu@none:52:50:55:157:3|g|T' ) ;
70
80
expect ( serializedBuckets ) . toContain ( 'lcp@second:1:1.2|d|#a:value,b:anothervalue|T' ) ;
71
81
expect ( serializedBuckets ) . toContain ( 'important_people@none:97:98|s|#numericKey:2|T' ) ;
82
+
83
+ _cleanupAggregator ( aggregator ) ;
72
84
} ) ;
73
85
} ) ;
74
86
} ) ;
0 commit comments