startStep method
Start a step within a transaction
Implementation
Future<void> startStep(
String stepName,
String transactionName, {
String? description,
int? startNanoTime,
}) async {
final hub = _hub;
if (!_isInitialized || hub == null) {
ObslyLogger.warn('PerformanceController not initialized');
return;
}
// Check if performance is enabled
final config = ConfigController.instance.config;
if (!(config?.enablePerformance ?? true)) {
ObslyLogger.debug('Performance disabled, ignoring startStep call');
return;
}
try {
final transaction = _activeTransactions[transactionName];
if (transaction == null) {
ObslyLogger.warn('Transaction not found for step: $transactionName');
return;
}
// Check if step already exists
if (transaction.activeSteps.containsKey(stepName)) {
ObslyLogger.warn('Step already started: $stepName in $transactionName');
return;
}
final step = PerformanceStep(
name: stepName,
description: description,
startTime: DateTime.now(),
startNanoTime: startNanoTime ?? DateTime.now().microsecondsSinceEpoch,
);
transaction.activeSteps[stepName] = step;
ObslyLogger.debug(
'📊 Performance step started: $stepName in $transactionName (stored state only)');
} catch (e) {
ObslyLogger.error('Error starting step: $e');
}
}