Skip to content

fix: Replace some workflows exception logging with warning and include context #4590

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions keep/parser/parser.py
Original file line number Diff line number Diff line change
@@ -539,9 +539,10 @@ def _get_step_provider(
provider = ProvidersFactory.get_provider(
context_manager, provider_id, step_provider_type, provider_config
)
except Exception:
self.logger.exception(
except Exception as ex:
self.logger.warning(
f"Error getting provider {provider_id} for step {_step.get('name')}",
exc_info=ex,
extra={
"workflow_name": workflow_id,
"workflow_description": workflow_description,
@@ -641,9 +642,10 @@ def _get_action(
provider_config,
**parsed_provider_parameters,
)
except Exception:
self.logger.exception(
except Exception as ex:
self.logger.warning(
f"Error getting provider {provider_id} for action {name}",
exc_info=ex,
extra={
"workflow_name": workflow_id,
"workflow_description": workflow_description,
11 changes: 9 additions & 2 deletions keep/providers/newrelic_provider/newrelic_provider.py
Original file line number Diff line number Diff line change
@@ -688,8 +688,15 @@ def __get_workflow_by_name_and_channel(
]["entities"]
# print(id_list)
return id_list[0]["id"]
except Exception:
self.logger.error("Error getting workflow by name and channel")
except Exception as ex:
self.logger.warning(
"Error getting workflow by name and channel",
exc_info=ex,
extra={
"name": name,
"channel_id": channel_id,
}
)

def __add_new_worflow(
self, channel_id: str, policy_ids: list, name: str
5 changes: 3 additions & 2 deletions keep/workflowmanager/workflowmanager.py
Original file line number Diff line number Diff line change
@@ -98,9 +98,10 @@ def _get_workflow_from_store(self, tenant_id, workflow_model):
"tenant_id": tenant_id,
},
)
except Exception:
self.logger.exception(
except Exception as ex:
self.logger.warning(
"Error getting workflow",
exc_info=ex,
extra={
"workflow_id": workflow_model.id,
"tenant_id": tenant_id,
18 changes: 12 additions & 6 deletions keep/workflowmanager/workflowscheduler.py
Original file line number Diff line number Diff line change
@@ -122,8 +122,11 @@ def _handle_interval_workflows(self):
try:
# get all workflows that should run due to interval
workflows = get_workflows_that_should_run()
except Exception:
self.logger.exception("Error getting workflows that should run")
except Exception as ex:
self.logger.warning(
"Error getting workflows that should run",
exc_info=ex,
)
pass
for workflow in workflows:
workflow_execution_id = workflow.get("workflow_execution_id")
@@ -150,8 +153,9 @@ def _handle_interval_workflows(self):
)
continue
except Exception as e:
self.logger.error(
self.logger.warning(
f"Error getting workflow: {e}",
exc_info=e,
extra={
"workflow_id": workflow_id,
"workflow_execution_id": workflow_execution_id,
@@ -434,8 +438,9 @@ def _handle_event_workflows(self):
)
# In case the provider are not configured properly
except ProviderConfigurationException as e:
self.logger.error(
self.logger.warning(
f"Error getting workflow: {e}",
exc_info=e,
extra={
"workflow_id": workflow_id,
"workflow_execution_id": workflow_execution_id,
@@ -451,8 +456,9 @@ def _handle_event_workflows(self):
)
continue
except Exception as e:
self.logger.error(
self.logger.warning(
f"Error getting workflow: {e}",
exc_info=e,
extra={
"workflow_id": workflow_id,
"workflow_execution_id": workflow_execution_id,
@@ -659,7 +665,7 @@ def _start(self):
except Exception:
# This is the "mainloop" of the scheduler, we don't want to crash it
# But any exception here should be investigated
self.logger.exception("Error getting workflows that should run")
self.logger.error("Error getting workflows that should run")
pass
self.logger.debug("Sleeping until next iteration")
time.sleep(1)