25
25
26
26
import com .uber .cadence .internal .metrics .ReplayAwareScope ;
27
27
import com .uber .cadence .internal .replay .ReplayAware ;
28
- import com .uber .m3 .tally .Buckets ;
29
28
import com .uber .m3 .tally .Counter ;
30
29
import com .uber .m3 .tally .Gauge ;
31
30
import com .uber .m3 .tally .Histogram ;
@@ -60,20 +59,21 @@ public void testReplayAwareScopeReplaying() {
60
59
Timer timer = mock (Timer .class );
61
60
Histogram histogram = mock (Histogram .class );
62
61
63
- Buckets buckets = ValueBuckets .linear (0 , 10 , 10 );
64
62
when (scope .counter ("test-counter" )).thenReturn (counter );
65
63
when (scope .gauge ("test-gauge" )).thenReturn (gauge );
66
64
when (scope .timer ("test-timer" )).thenReturn (timer );
67
- when (scope .histogram ("test-histogram" , buckets )).thenReturn (histogram );
65
+ when (scope .histogram ("test-histogram" , ValueBuckets . linear ( 0 , 10 , 10 ) )).thenReturn (histogram );
68
66
69
67
TestContext context = new TestContext (true );
70
68
Scope replayAwareScope = new ReplayAwareScope (scope , context , System ::currentTimeMillis );
71
69
72
70
replayAwareScope .counter ("test-counter" ).inc (1 );
73
71
replayAwareScope .gauge ("test-gauge" ).update (100.0 );
74
72
replayAwareScope .timer ("test-timer" ).record (Duration .ofMillis (100 ));
75
- replayAwareScope .histogram ("test-histogram" , buckets ).recordValue (10 );
76
- replayAwareScope .histogram ("test-histogram" , buckets ).recordDuration (Duration .ofHours (1 ));
73
+ replayAwareScope .histogram ("test-histogram" , ValueBuckets .linear (0 , 10 , 10 )).recordValue (10 );
74
+ replayAwareScope
75
+ .histogram ("test-histogram" , ValueBuckets .linear (0 , 10 , 10 ))
76
+ .recordDuration (Duration .ofHours (1 ));
77
77
78
78
verify (counter , never ()).inc (1 );
79
79
verify (gauge , never ()).update (100.0 );
@@ -90,20 +90,21 @@ public void testReplayAwareScopeNotReplaying() {
90
90
Timer timer = mock (Timer .class );
91
91
Histogram histogram = mock (Histogram .class );
92
92
93
- Buckets buckets = ValueBuckets .linear (0 , 10 , 10 );
94
93
when (scope .counter ("test-counter" )).thenReturn (counter );
95
94
when (scope .gauge ("test-gauge" )).thenReturn (gauge );
96
95
when (scope .timer ("test-timer" )).thenReturn (timer );
97
- when (scope .histogram ("test-histogram" , buckets )).thenReturn (histogram );
96
+ when (scope .histogram ("test-histogram" , ValueBuckets . linear ( 0 , 10 , 10 ) )).thenReturn (histogram );
98
97
99
98
TestContext context = new TestContext (false );
100
99
Scope replayAwareScope = new ReplayAwareScope (scope , context , System ::currentTimeMillis );
101
100
102
101
replayAwareScope .counter ("test-counter" ).inc (1 );
103
102
replayAwareScope .gauge ("test-gauge" ).update (100.0 );
104
103
replayAwareScope .timer ("test-timer" ).record (Duration .ofMillis (100 ));
105
- replayAwareScope .histogram ("test-histogram" , buckets ).recordValue (10 );
106
- replayAwareScope .histogram ("test-histogram" , buckets ).recordDuration (Duration .ofHours (1 ));
104
+ replayAwareScope .histogram ("test-histogram" , ValueBuckets .linear (0 , 10 , 10 )).recordValue (10 );
105
+ replayAwareScope
106
+ .histogram ("test-histogram" , ValueBuckets .linear (0 , 10 , 10 ))
107
+ .recordDuration (Duration .ofHours (1 ));
107
108
108
109
verify (counter , times (1 )).inc (1 );
109
110
verify (gauge , times (1 )).update (100.0 );
@@ -131,9 +132,8 @@ public void testCustomClockForTimer() {
131
132
Timer timer = mock (Timer .class );
132
133
Histogram histogram = mock (Histogram .class );
133
134
134
- Buckets buckets = ValueBuckets .linear (0 , 10 , 10 );
135
135
when (scope .timer ("test-timer" )).thenReturn (timer );
136
- when (scope .histogram ("test-histogram" , buckets )).thenReturn (histogram );
136
+ when (scope .histogram ("test-histogram" , ValueBuckets . linear ( 0 , 10 , 10 ) )).thenReturn (histogram );
137
137
138
138
TestContext context = new TestContext (false );
139
139
TestClock clock = new TestClock ();
@@ -143,7 +143,7 @@ public void testCustomClockForTimer() {
143
143
clock .setTime (100 );
144
144
sw .stop ();
145
145
146
- sw = replayAwareScope .histogram ("test-histogram" , buckets ).start ();
146
+ sw = replayAwareScope .histogram ("test-histogram" , ValueBuckets . linear ( 0 , 10 , 10 ) ).start ();
147
147
clock .setTime (150 );
148
148
sw .stop ();
149
149
0 commit comments