Skip to content

Commit

Permalink
fix(api): logs leak (#2941)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl authored Dec 30, 2024
1 parent cc381ee commit 9c5a6d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions keep/api/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

KEEP_STORE_WORKFLOW_LOGS = (
os.environ.get("KEEP_STORE_WORKFLOW_LOGS", "true").lower() == "true"
)


class WorkflowDBHandler(logging.Handler):
def __init__(self):
Expand All @@ -25,6 +29,8 @@ def __init__(self):

def emit(self, record):
# we want to push only workflow logs to the DB
if not KEEP_STORE_WORKFLOW_LOGS:
return
if hasattr(record, "workflow_execution_id") and record.workflow_execution_id:
self.records.append(record)

Expand Down Expand Up @@ -155,6 +161,7 @@ def dump(self):
None,
)
if workflow_db_handler:
self.logger.info("Pushing logs to DB")
workflow_db_handler.push_logs_to_db()
else:
self.logger.warning("No WorkflowDBHandler found")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.33.4"
version = "0.33.5"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down

0 comments on commit 9c5a6d5

Please sign in to comment.