Enhancement: Track and Log Script Runtime Duration #6

Closed
opened 2025-04-15 09:52:11 -04:00 by nick · 1 comment
Owner

Description

Add support to 753 Data Sync for tracking and logging the total execution time of the script in a human-readable format. This enhancement improves observability and can help identify performance issues in long-running data sync operations.


Proposed Behavior

At the end of script execution (in the finally block of the main() function), the script should:

  • Record the start time at the beginning of execution.
  • Calculate total elapsed time at the end.
  • Log the elapsed time using the existing logging system in HH:MM:SS format.

Benefits

  • Helps developers and operators quickly see how long the script ran.
  • Supports performance monitoring and tuning.
  • Adds minimal overhead (uses built-in Python modules).
  • Keeps logs more informative and complete.

Implementation Notes

  • Use Python’s time.time() to capture start and end timestamps.
  • Format elapsed time using datetime.timedelta for clean display (HH:MM:SS).
  • Add the elapsed time log as an INFO-level message in the finally block of the main() function.

Example Log Output

2025-04-15 14:32:12 - INFO - Script execution completed in 0:04:19.
#### **Description** Add support to **753 Data Sync** for tracking and logging the total execution time of the script in a human-readable format. This enhancement improves observability and can help identify performance issues in long-running data sync operations. --- #### **Proposed Behavior** At the end of script execution (in the `finally` block of the `main()` function), the script should: - Record the start time at the beginning of execution. - Calculate total elapsed time at the end. - Log the elapsed time using the existing logging system in `HH:MM:SS` format. --- #### **Benefits** - Helps developers and operators quickly see how long the script ran. - Supports performance monitoring and tuning. - Adds minimal overhead (uses built-in Python modules). - Keeps logs more informative and complete. --- #### **Implementation Notes** - Use Python’s `time.time()` to capture start and end timestamps. - Format elapsed time using `datetime.timedelta` for clean display (`HH:MM:SS`). - Add the elapsed time log as an `INFO`-level message in the `finally` block of the `main()` function. --- #### **Example Log Output** ``` 2025-04-15 14:32:12 - INFO - Script execution completed in 0:04:19. ```
nick added the
enhancement
label 2025-04-15 09:52:11 -04:00
nick self-assigned this 2025-04-15 09:52:11 -04:00
nick changed title from Enhancement: Add Script Execution Time Logging to Enhancement: Track and Log Script Runtime Duration 2025-04-15 16:52:43 -04:00
nick added reference enhancement/log-execution-time 2025-04-15 17:15:48 -04:00
Author
Owner

This has been merged into master.

This has been [merged](https://git.nickhepler.cloud/nick/753-Data-Sync/pulls/7) into master.
nick closed this issue 2025-04-15 17:34:54 -04:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: nick/753-Data-Sync#6
No description provided.