startHistogramTimer method
void
startHistogramTimer(})
Start a histogram timer (only stores timestamp, no event generated)
Implementation
void startHistogramTimer(
String key,
String? fbl,
String? operation,
String? view, {
int? timestamp,
}) {
if (!_isInitialized || _hub == null) {
ObslyLogger.warn('MetricsController not initialized');
return;
}
// Check if metrics is enabled
final config = ConfigController.instance.config;
if (!(config?.enableMetrics ?? true)) {
ObslyLogger.debug('Metrics disabled, ignoring startHistogramTimer call');
return;
}
if (!_isTimerSessionValid()) {
ObslyLogger.warn('Invalid session for histogram timer');
return;
}
try {
final timerKey = _createTimerKey(key, fbl, operation, view);
// Check if timer already exists
if (_histogramTimers.containsKey(timerKey)) {
ObslyLogger.warn('Timer already started for key: $timerKey');
return;
}
// Store timestamp (use provided timestamp or current time)
final startTime = timestamp ?? DateTime.now().millisecondsSinceEpoch;
_histogramTimers[timerKey] = startTime;
ObslyLogger.debug('📊 Histogram timer started: $timerKey');
} catch (e) {
ObslyLogger.error('Error starting histogram timer: $e');
}
}