recordMetric method

  1. @override
Future<ResultDart<void, TelemetryException>> recordMetric({
  1. required String name,
  2. required String metricType,
  3. required double value,
  4. String unit = 'count',
  5. Map<String, String> attributes = const {},
})
override

Records a counter metric.

Returns ResultDart with success or TelemetryException on error.

Implementation

@override
Future<ResultDart<void, TelemetryException>> recordMetric({
  required String name,
  required String metricType,
  required double value,
  String unit = 'count',
  Map<String, String> attributes = const {},
}) async {
  final metric = Metric(
    name: name,
    value: value,
    unit: unit,
    timestamp: DateTime.now().toUtc(),
    attributes: attributes,
  );

  await _repository.exportMetric(metric);
  return Success(unit);
}