@@ -16,13 +16,13 @@ describe('MetricsStore concurrent invocation isolation', () => {
1616 expectedResult1 : {
1717 name : 'count' ,
1818 unit : MetricUnit . Count ,
19- value : 2 ,
19+ value : [ 1 , 2 ] ,
2020 resolution : 60 ,
2121 } ,
2222 expectedResult2 : {
2323 name : 'count' ,
2424 unit : MetricUnit . Count ,
25- value : 2 ,
25+ value : [ 1 , 2 ] ,
2626 resolution : 60 ,
2727 } ,
2828 } ,
@@ -47,27 +47,19 @@ describe('MetricsStore concurrent invocation isolation', () => {
4747 async ( { useInvokeStore, expectedResult1, expectedResult2 } ) => {
4848 // Prepare
4949 const store = new MetricsStore ( ) ;
50- const metric1 : StoredMetric = {
51- name : 'count' ,
52- unit : MetricUnit . Count ,
53- value : 1 ,
54- resolution : 60 ,
55- } ;
56- const metric2 : StoredMetric = {
57- name : 'count' ,
58- unit : MetricUnit . Count ,
59- value : 2 ,
60- resolution : 60 ,
61- } ;
6250
6351 // Act
6452 const [ result1 , result2 ] = await sequence (
6553 {
66- sideEffects : [ ( ) => store . setMetric ( 'count' , metric1 ) ] ,
54+ sideEffects : [
55+ ( ) => store . setMetric ( 'count' , MetricUnit . Count , 1 , 60 ) ,
56+ ] ,
6757 return : ( ) => store . getMetric ( 'count' ) ,
6858 } ,
6959 {
70- sideEffects : [ ( ) => store . setMetric ( 'count' , metric2 ) ] ,
60+ sideEffects : [
61+ ( ) => store . setMetric ( 'count' , MetricUnit . Count , 2 , 60 ) ,
62+ ] ,
7163 return : ( ) => store . getMetric ( 'count' ) ,
7264 } ,
7365 { useInvokeStore }
@@ -122,16 +114,16 @@ describe('MetricsStore concurrent invocation isolation', () => {
122114 {
123115 sideEffects : [
124116 ( ) => {
125- store . setMetric ( 'count' , countMetric ) ;
126- store . setMetric ( 'latency' , latencyMetric ) ;
117+ store . setMetric ( 'count' , MetricUnit . Count , 1 , 60 ) ;
118+ store . setMetric ( 'latency' , MetricUnit . Milliseconds , 100 , 60 ) ;
127119 } ,
128120 ] ,
129121 return : ( ) => store . getAllMetrics ( ) ,
130122 } ,
131123 {
132124 sideEffects : [
133125 ( ) => {
134- store . setMetric ( 'errors' , errorMetric ) ;
126+ store . setMetric ( 'errors' , MetricUnit . Count , 1 , 60 ) ;
135127 } ,
136128 ] ,
137129 return : ( ) => store . getAllMetrics ( ) ,
@@ -203,19 +195,13 @@ describe('MetricsStore concurrent invocation isolation', () => {
203195 async ( { useInvokeStore, expectedResult1, expectedResult2 } ) => {
204196 // Prepare
205197 const store = new MetricsStore ( ) ;
206- const countMetric : StoredMetric = {
207- name : 'count' ,
208- unit : MetricUnit . Count ,
209- value : 1 ,
210- resolution : 60 ,
211- } ;
212198
213199 // Act
214200 const [ result1 , result2 ] = await sequence (
215201 {
216202 sideEffects : [
217203 ( ) => {
218- store . setMetric ( 'count' , countMetric ) ;
204+ store . setMetric ( 'count' , MetricUnit . Count , 1 , 60 ) ;
219205 store . setTimestamp ( 1000 ) ;
220206 } ,
221207 ( ) => { } , // Wait for inv2 to add
@@ -230,7 +216,7 @@ describe('MetricsStore concurrent invocation isolation', () => {
230216 sideEffects : [
231217 ( ) => { } , // Wait for inv1 to add
232218 ( ) => {
233- store . setMetric ( 'errors' , errorMetric ) ;
219+ store . setMetric ( 'errors' , MetricUnit . Count , 1 , 60 ) ;
234220 store . setTimestamp ( 2000 ) ;
235221 } ,
236222 ( ) => { } , // Wait for clear
@@ -267,17 +253,13 @@ describe('MetricsStore concurrent invocation isolation', () => {
267253 async ( { useInvokeStore, expectedResult1, expectedResult2 } ) => {
268254 // Prepare
269255 const store = new MetricsStore ( ) ;
270- const metric : StoredMetric = {
271- name : 'count' ,
272- unit : MetricUnit . Count ,
273- value : 1 ,
274- resolution : 60 ,
275- } ;
276256
277257 // Act
278258 const [ result1 , result2 ] = await sequence (
279259 {
280- sideEffects : [ ( ) => store . setMetric ( 'count' , metric ) ] ,
260+ sideEffects : [
261+ ( ) => store . setMetric ( 'count' , MetricUnit . Count , 1 , 60 ) ,
262+ ] ,
281263 return : ( ) => store . hasMetrics ( ) ,
282264 } ,
283265 {
@@ -311,27 +293,19 @@ describe('MetricsStore concurrent invocation isolation', () => {
311293 async ( { useInvokeStore, expectedResult1, expectedResult2 } ) => {
312294 // Prepare
313295 const store = new MetricsStore ( ) ;
314- const metric1 : StoredMetric = {
315- name : 'count' ,
316- unit : MetricUnit . Count ,
317- value : 1 ,
318- resolution : 60 ,
319- } ;
320- const metric2 : StoredMetric = {
321- name : 'errors' ,
322- unit : MetricUnit . Count ,
323- value : 1 ,
324- resolution : 60 ,
325- } ;
326296
327297 // Act
328298 const [ result1 , result2 ] = await sequence (
329299 {
330- sideEffects : [ ( ) => store . setMetric ( 'count' , metric1 ) ] ,
300+ sideEffects : [
301+ ( ) => store . setMetric ( 'count' , MetricUnit . Count , 1 , 60 ) ,
302+ ] ,
331303 return : ( ) => store . getMetricsCount ( ) ,
332304 } ,
333305 {
334- sideEffects : [ ( ) => store . setMetric ( 'errors' , metric2 ) ] ,
306+ sideEffects : [
307+ ( ) => store . setMetric ( 'errors' , MetricUnit . Count , 1 , 60 ) ,
308+ ] ,
335309 return : ( ) => store . getMetricsCount ( ) ,
336310 } ,
337311 { useInvokeStore }
0 commit comments