getStartTime abstract method

DateTime getStartTime()

Returns the startup time of this context as a DateTime.

The startup time represents when the context transitioned to active state after successful refresh. This is useful for:

Use Cases:

  • Uptime Monitoring: Calculate how long the context has been running
  • Performance Analysis: Measure initialization time and track over restarts
  • Logging and Auditing: Correlate events with context lifetime
  • Scheduling: Schedule tasks relative to context startup

Example:

final startTime = context.getStartTime();
final uptime = DateTime.now().difference(startTime);

print('Context started: ${DateFormat('yyyy-MM-dd HH:mm:ss').format(startTime)}');
print('Uptime: ${uptime.inHours}h ${uptime.inMinutes.remainder(60)}m');

// Use in monitoring
if (uptime.inDays > 30) {
  logger.warn('Context has been running for over 30 days');
}

Implementation

DateTime getStartTime();