-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metrics Part 1 - Add Counter Metric API (#1940)
Add Counter Metric API (part 1) (#1940) * added Counter Metric API * added Metric Aggregation, with hub/client integration and close * added metric tag normalization * added send of statsd envelope type Add other metric types and weight (part 2) (#1949) * added crc32_utils.dart, taken from archive library * added Gauge, Distribution and Set metrics * added weight to Metrics and auto flush when weight is too much Add timing metric and beforeMetric callback (part 3) (#1954) * added SentryOptions.beforeMetricCallback * added beforeMetricCallback logic in metrics_aggregator.dart * added timing metric api with span auto start * timing api uses span duration as value for the emitted metric if possible Add metrics span summary (part 4) (#1958) * added local_metrics_aggregator.dart to spans * metrics_aggregator.dart now adds to current span's localMetricsAggregator * added metric_summary.dart * added metricSummary to spans and transaction JSONs Add rate limit (part 5) (#1973) * added metric_bucket data category for rate limits * updated metric normalization rules * added rate limit for metrics
- Loading branch information
1 parent
61e71ec
commit 84bc635
Showing
48 changed files
with
3,021 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'dart:core'; | ||
import 'package:meta/meta.dart'; | ||
import '../protocol/metric_summary.dart'; | ||
import 'metric.dart'; | ||
|
||
@internal | ||
class LocalMetricsAggregator { | ||
// format: <export key, <metric key, gauge>> | ||
final Map<String, Map<String, GaugeMetric>> _buckets = {}; | ||
|
||
void add(final Metric metric, final num value) { | ||
final bucket = | ||
_buckets.putIfAbsent(metric.getSpanAggregationKey(), () => {}); | ||
|
||
bucket.update(metric.getCompositeKey(), (m) => m..add(value), | ||
ifAbsent: () => Metric.fromType( | ||
type: MetricType.gauge, | ||
key: metric.key, | ||
value: value, | ||
unit: metric.unit, | ||
tags: metric.tags) as GaugeMetric); | ||
} | ||
|
||
Map<String, List<MetricSummary>> getSummaries() { | ||
final Map<String, List<MetricSummary>> summaries = {}; | ||
for (final entry in _buckets.entries) { | ||
final String exportKey = entry.key; | ||
|
||
final metricSummaries = entry.value.values | ||
.map((gauge) => MetricSummary.fromGauge(gauge)) | ||
.toList(); | ||
|
||
summaries[exportKey] = metricSummaries; | ||
} | ||
return summaries; | ||
} | ||
} |
Oops, something went wrong.