@@ -50,10 +50,9 @@ class MetricsAggregator {
50
50
return ;
51
51
}
52
52
53
- final int bucketKey = _getBucketKey (_options.clock ());
54
- final Map <String , Metric > bucket =
55
- _buckets.putIfAbsent (bucketKey, () => {});
56
- final Metric metric =
53
+ final bucketKey = _getBucketKey (_options.clock ());
54
+ final bucket = _buckets.putIfAbsent (bucketKey, () => {});
55
+ final metric =
57
56
CounterMetric (value: value, key: key, unit: unit, tags: tags);
58
57
59
58
// Update the existing metric in the bucket.
@@ -90,7 +89,7 @@ class MetricsAggregator {
90
89
91
90
/// Flush and sends metrics.
92
91
Future <void > _flush () async {
93
- final Iterable < int > flushableBucketKeys = _getFlushableBucketKeys ();
92
+ final flushableBucketKeys = _getFlushableBucketKeys ();
94
93
if (flushableBucketKeys.isEmpty) {
95
94
_options.logger (SentryLevel .debug, 'Metrics: nothing to flush' );
96
95
return ;
@@ -100,7 +99,7 @@ class MetricsAggregator {
100
99
int numMetrics = 0 ;
101
100
102
101
for (int flushableBucketKey in flushableBucketKeys) {
103
- final Map < String , Metric > ? bucket = _buckets.remove (flushableBucketKey);
102
+ final bucket = _buckets.remove (flushableBucketKey);
104
103
if (bucket != null ) {
105
104
numMetrics += bucket.length;
106
105
bucketsToFlush[flushableBucketKey] = bucket.values;
@@ -120,11 +119,11 @@ class MetricsAggregator {
120
119
List <int > _getFlushableBucketKeys () {
121
120
// Flushable buckets are all buckets with timestamp lower than the current
122
121
// one (so now - rollupInSeconds), minus a random duration (flushShiftMs).
123
- final DateTime maxTimestampToFlush = _options.clock ().subtract (Duration (
122
+ final maxTimestampToFlush = _options.clock ().subtract (Duration (
124
123
seconds: _rollupInSeconds,
125
124
milliseconds: _flushShiftMs,
126
125
));
127
- final int maxKeyToFlush = _getBucketKey (maxTimestampToFlush);
126
+ final maxKeyToFlush = _getBucketKey (maxTimestampToFlush);
128
127
129
128
// takeWhile works because we use a SplayTreeMap and keys are ordered.
130
129
// toList() is needed because takeWhile is lazy and we want to remove items
@@ -134,7 +133,7 @@ class MetricsAggregator {
134
133
135
134
/// The timestamp of the bucket, rounded down to the nearest RollupInSeconds.
136
135
int _getBucketKey (DateTime timestamp) {
137
- final int seconds = timestamp.millisecondsSinceEpoch ~ / 1000 ;
136
+ final seconds = timestamp.millisecondsSinceEpoch ~ / 1000 ;
138
137
return (seconds ~ / _rollupInSeconds) * _rollupInSeconds;
139
138
}
140
139
0 commit comments