captureMetrics method

  1. @internal
Future<SentryId> captureMetrics(
  1. Map<int, Iterable<Metric>> metricsBuckets
)

Implementation

@internal
Future<SentryId> captureMetrics(
    Map<int, Iterable<Metric>> metricsBuckets) async {
  var sentryId = SentryId.empty();

  if (!_isEnabled) {
    _options.logger(
      SentryLevel.warning,
      "Instance is disabled and this 'captureMetrics' call is a no-op.",
    );
  } else if (!_options.enableMetrics) {
    _options.logger(
      SentryLevel.info,
      "Metrics are disabled and this 'captureMetrics' call is a no-op.",
    );
  } else if (metricsBuckets.isEmpty) {
    _options.logger(
      SentryLevel.info,
      "Metrics are empty and this 'captureMetrics' call is a no-op.",
    );
  } else {
    final item = _peek();
    try {
      sentryId = await item.client.captureMetrics(metricsBuckets);
    } catch (exception, stackTrace) {
      _options.logger(
        SentryLevel.error,
        'Error while capturing metrics.',
        exception: exception,
        stackTrace: stackTrace,
      );
    }
  }
  return sentryId;
}