Skip to content

Commit a22e451

Browse files
authored
Remove metrics API (#2571)
* first removals * remove metrics api * update changelog * auto format * update mocks * remove metrics from tests * update changelog * remove empty file * update zendesk link * dont delete metric.yml * fix mocks
1 parent a43c400 commit a22e451

35 files changed

+97
-1662
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### Breaking changes
6+
7+
- Remove Metrics API ([#2571](https://github.com/getsentry/sentry-dart/pull/2571))
8+
- The Metrics product never reached maturity from beta and has officially ended in October 7th, 2024
9+
- Read [this post](https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Metrics-Beta-Ended-on-October-7th) for more information
10+
511
### Features
612

713
- Add `beforeCapture` for View Hierarchy ([#2523](https://github.com/getsentry/sentry-dart/pull/2523))

dart/lib/src/hub.dart

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import 'dart:async';
22
import 'dart:collection';
33

44
import 'package:meta/meta.dart';
5-
import 'metrics/metric.dart';
6-
import 'metrics/metrics_aggregator.dart';
7-
import 'metrics/metrics_api.dart';
8-
import 'profiling.dart';
9-
import 'propagation_context.dart';
10-
import 'transport/data_category.dart';
115

126
import '../sentry.dart';
137
import 'client_reports/discard_reason.dart';
8+
import 'profiling.dart';
9+
import 'propagation_context.dart';
1410
import 'sentry_tracer.dart';
1511
import 'sentry_traces_sampler.dart';
12+
import 'transport/data_category.dart';
1613

1714
/// Configures the scope through the callback.
1815
typedef ScopeCallback = FutureOr<void> Function(Scope);
@@ -41,16 +38,6 @@ class Hub {
4138

4239
late final _WeakMap _throwableToSpan;
4340

44-
late final MetricsApi _metricsApi;
45-
46-
@internal
47-
@Deprecated(
48-
'Metrics will be deprecated and removed in the next major release. Sentry will reject all metrics sent after October 7, 2024. Learn more: https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics')
49-
MetricsApi get metricsApi => _metricsApi;
50-
51-
@internal
52-
MetricsAggregator? get metricsAggregator => _peek().client.metricsAggregator;
53-
5441
factory Hub(SentryOptions options) {
5542
_validateOptions(options);
5643

@@ -62,7 +49,6 @@ class Hub {
6249
_stack.add(_StackItem(_getClient(_options), Scope(_options)));
6350
_isEnabled = true;
6451
_throwableToSpan = _WeakMap(_options);
65-
_metricsApi = MetricsApi(hub: this);
6652
}
6753

6854
static void _validateOptions(SentryOptions options) {
@@ -634,45 +620,6 @@ class Hub {
634620
return sentryId;
635621
}
636622

637-
@internal
638-
Future<SentryId> captureMetrics(
639-
Map<int, Iterable<Metric>> metricsBuckets) async {
640-
var sentryId = SentryId.empty();
641-
642-
if (!_isEnabled) {
643-
_options.logger(
644-
SentryLevel.warning,
645-
"Instance is disabled and this 'captureMetrics' call is a no-op.",
646-
);
647-
} else if (!_options.enableMetrics) {
648-
_options.logger(
649-
SentryLevel.info,
650-
"Metrics are disabled and this 'captureMetrics' call is a no-op.",
651-
);
652-
} else if (metricsBuckets.isEmpty) {
653-
_options.logger(
654-
SentryLevel.info,
655-
"Metrics are empty and this 'captureMetrics' call is a no-op.",
656-
);
657-
} else {
658-
final item = _peek();
659-
try {
660-
sentryId = await item.client.captureMetrics(metricsBuckets);
661-
} catch (exception, stackTrace) {
662-
_options.logger(
663-
SentryLevel.error,
664-
'Error while capturing metrics.',
665-
exception: exception,
666-
stackTrace: stackTrace,
667-
);
668-
if (_options.automatedTestMode) {
669-
rethrow;
670-
}
671-
}
672-
}
673-
return sentryId;
674-
}
675-
676623
@internal
677624
void setSpanContext(
678625
dynamic throwable,

dart/lib/src/hub_adapter.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import 'package:meta/meta.dart';
44

55
import 'hint.dart';
66
import 'hub.dart';
7-
import 'metrics/metric.dart';
8-
import 'metrics/metrics_aggregator.dart';
9-
import 'metrics/metrics_api.dart';
107
import 'profiling.dart';
118
import 'protocol.dart';
129
import 'protocol/sentry_feedback.dart';
@@ -27,11 +24,6 @@ class HubAdapter implements Hub {
2724
@internal
2825
SentryOptions get options => Sentry.currentHub.options;
2926

30-
@override
31-
@internal
32-
// ignore: deprecated_member_use_from_same_package
33-
MetricsApi get metricsApi => Sentry.currentHub.metricsApi;
34-
3527
factory HubAdapter() {
3628
return _instance;
3729
}
@@ -193,14 +185,6 @@ class HubAdapter implements Hub {
193185
@override
194186
Scope get scope => Sentry.currentHub.scope;
195187

196-
@override
197-
Future<SentryId> captureMetrics(Map<int, Iterable<Metric>> metricsBuckets) =>
198-
Sentry.currentHub.captureMetrics(metricsBuckets);
199-
200-
@override
201-
MetricsAggregator? get metricsAggregator =>
202-
Sentry.currentHub.metricsAggregator;
203-
204188
@override
205189
Future<SentryId> captureFeedback(
206190
SentryFeedback feedback, {

dart/lib/src/metrics/local_metrics_aggregator.dart

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)