recordGauge method

  1. @override
Future<void> recordGauge({
  1. required String name,
  2. required double value,
  3. Map<String, String> attributes = const {},
})
override

Records a gauge metric (current value).

Use for measurements like pool size, active connections. Returns Future<void> to allow for async repository operations.

Implementation

@override
Future<void> recordGauge({
  required String name,
  required double value,
  Map<String, String> attributes = const {},
}) async {
  if (name.isEmpty) {
    throw ArgumentError('Gauge name cannot be empty');
  }
  if (value.isNaN || value.isInfinite) {
    throw ArgumentError('Gauge value must be a valid number');
  }

  await safely(
    'exportMetric',
    () => _repository.exportMetric(
      Metric(
        name: name,
        value: value,
        unit: 'count',
        timestamp: DateTime.now().toUtc(),
        attributes: attributes,
      ),
    ),
  );
}