-
Notifications
You must be signed in to change notification settings - Fork 30
feat: track log line count per workflow and task to enable log truncation observability #758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "operations": [ | ||
| { | ||
| "sql": { | ||
| "up": "ALTER TABLE workflows ADD COLUMN IF NOT EXISTS log_line_count INTEGER;" | ||
| } | ||
| }, | ||
| { | ||
| "sql": { | ||
| "up": "ALTER TABLE tasks ADD COLUMN IF NOT EXISTS log_line_count INTEGER;" | ||
| } | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -246,6 +246,7 @@ def execute(self, context: JobExecutionContext, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_obj_spec.resources.memory or '0', 'GiB'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| json.dumps(task_obj.exit_actions, default=common.pydantic_encoder), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_obj.lead, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task.Task.batch_insert_to_db(postgres, task_entries) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| progress_writer.report_progress() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1505,13 +1506,26 @@ async def run_log_migrations(): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_obj.update_log_to_db(wf_logs_ss_file_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_obj.update_events_to_db(wf_events_ss_file_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Read and persist log line counts before deleting Redis keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_log_count_key = f'{self.workflow_id}-log-count' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_log_count_raw = redis_client.get(workflow_log_count_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if workflow_log_count_raw is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_obj.update_log_line_count_to_db(int(workflow_log_count_raw)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove logs from Redis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis_keys_to_delete : List[str] = [workflow_logs_redis_key, workflow_events_redis_key] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis_keys_to_delete : List[str] = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_logs_redis_key, workflow_events_redis_key, workflow_log_count_key] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for group in workflow_obj.groups: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for task_obj in group.tasks: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_redis_path = common.get_redis_task_log_name( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.workflow_id, task_obj.name, task_obj.retry_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis_keys_to_delete.append(task_redis_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_log_count_key = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| f'{self.workflow_id}-{task_obj.name}-{task_obj.retry_id}-log-count') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_log_count_raw = redis_client.get(task_log_count_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if task_log_count_raw is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task_obj.update_log_line_count_to_db(int(task_log_count_raw)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis_keys_to_delete.append(task_log_count_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1509
to
+1528
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finalize missing Redis counters as Lines 1512-1513 and Lines 1526-1527 only persist 💡 Suggested fix- workflow_log_count_raw = redis_client.get(workflow_log_count_key)
- if workflow_log_count_raw is not None:
- workflow_obj.update_log_line_count_to_db(int(workflow_log_count_raw))
+ workflow_log_count_raw = redis_client.get(workflow_log_count_key)
+ workflow_log_count = 0 if workflow_log_count_raw is None else int(workflow_log_count_raw)
+ workflow_obj.update_log_line_count_to_db(workflow_log_count)
@@
- task_log_count_raw = redis_client.get(task_log_count_key)
- if task_log_count_raw is not None:
- task_obj.update_log_line_count_to_db(int(task_log_count_raw))
+ task_log_count_raw = redis_client.get(task_log_count_key)
+ task_log_count = 0 if task_log_count_raw is None else int(task_log_count_raw)
+ task_obj.update_log_line_count_to_db(task_log_count)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if task_obj.status.has_error_logs(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prefix = f'{self.workflow_id}-{task_obj.task_uuid}-{task_obj.retry_id}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis_keys_to_delete.append(f'{prefix}-error-logs') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match the fixture's
workflows.pooldefinition to production.src/utils/connectors/postgres.pystill defines this column as nullable, but this fixture makes itNOT NULL DEFAULT ''. That changesNULLvs empty-string behavior and can hide bugs that only show up against the real schema.🔧 Suggested change
CREATE TABLE IF NOT EXISTS workflows ( workflow_id TEXT PRIMARY KEY, - pool TEXT NOT NULL DEFAULT '', + pool TEXT, log_line_count INTEGER );📝 Committable suggestion
🤖 Prompt for AI Agents