62 default:
return "unknown";
188 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
192 std::strftime(buffer,
sizeof(buffer),
"%Y-%m-%dT%H:%M:%S",
193 std::gmtime(&time_t));
195 return std::string(buffer) +
"." +
196 std::to_string(ms.count()) +
"Z";
205 return std::chrono::duration<double, std::milli>(
wait_time).count();
214 return std::chrono::duration<double, std::milli>(
execution_time).count();
261 std::ostringstream oss;
263 oss <<
" \"event_id\": " <<
event_id <<
",\n";
264 oss <<
" \"job_id\": " <<
job_id <<
",\n";
265 oss <<
" \"job_name\": \"" <<
job_name <<
"\",\n";
270 std::ostringstream tid_oss;
272 oss <<
" \"thread_id\": \"" << tid_oss.str() <<
"\",\n";
274 oss <<
" \"worker_id\": " <<
worker_id <<
",\n";
275 oss << std::fixed << std::setprecision(3);
276 oss <<
" \"wait_time_ms\": " <<
wait_time_ms() <<
",\n";
281 oss <<
",\n \"error_code\": " <<
error_code.value();
285 oss <<
",\n \"error_code\": null";
290 oss <<
",\n \"error_message\": \"" <<
error_message.value() <<
"\"";
294 oss <<
",\n \"error_message\": null";
313 std::ostringstream oss;
324 oss << std::fixed << std::setprecision(3);
Interface for receiving job execution events.
virtual void on_event(const job_execution_event &event)=0
Called when a job execution event occurs.
virtual ~execution_event_listener()=default
Virtual destructor.
event_type
Type of job execution event.
@ dequeued
Job was taken from queue by a worker.
@ failed
Job failed with an error.
@ cancelled
Job was cancelled.
@ started
Job execution started.
@ retried
Job is being retried after failure.
@ completed
Job completed successfully.
@ enqueued
Job was added to the queue.
auto event_type_to_string(event_type type) -> std::string
Converts event_type to human-readable string.
error_code
Strongly typed error codes for thread system operations.
std::uint64_t job_id
Unique job identifier for DAG scheduler.
Event data for job execution tracing.
std::string job_name
Human-readable name of the job.
std::chrono::nanoseconds wait_time
Time spent waiting in queue before dequeue.
std::optional< std::string > error_message
Error message if the job failed.
std::chrono::nanoseconds execution_time
Time spent executing the job.
std::uint64_t event_id
Unique identifier for this event.
event_type type
Type of event that occurred.
auto wait_time_ms() const -> double
Converts wait_time to milliseconds.
std::optional< int > error_code
Error code if the job failed.
auto is_error() const -> bool
Checks if this event indicates an error.
auto execution_time_ms() const -> double
Converts execution_time to milliseconds.
auto to_string() const -> std::string
Converts the event to a human-readable string.
std::size_t worker_id
Worker ID that processed this job.
auto is_terminal() const -> bool
Checks if this is a terminal event (job finished).
auto to_json() const -> std::string
Converts the event to a JSON string.
auto format_timestamp() const -> std::string
Formats the event timestamp as ISO 8601 string.
std::thread::id thread_id
ID of the thread that processed this event.
std::chrono::system_clock::time_point system_timestamp
System time when the event occurred.
std::chrono::steady_clock::time_point timestamp
Time when the event occurred.