Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl committed Jan 6, 2025
1 parent 067df4a commit bd59e8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
31 changes: 10 additions & 21 deletions keep/api/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import urllib3
from sqlmodel import Session

from keep.api.consts import RUNNING_IN_CLOUD_RUN
from keep.api.core.db import get_session, push_logs_to_db
from keep.api.models.db.provider import ProviderExecutionLog

Expand Down Expand Up @@ -140,26 +139,16 @@ def process(self, msg, kwargs):

def dump(self):
self.logger.info("Dumping workflow logs")
# TODO - this is a POC level code.
# TODO - we should:
# TODO - 1. find the right handler to push the logs to the DB
# TODO - 2. find a better way to push the logs async (maybe another service)
workflow_db_handler = next(
iter(
[
handler
for handler in (
# tb: for some reason, when running in cloud run, the handler is nested in another handler
# this needs to be handled in a better way
self.logger.parent.parent.handlers
if RUNNING_IN_CLOUD_RUN
else self.logger.parent.handlers
)
if isinstance(handler, WorkflowDBHandler)
]
),
None,
)
root_logger = logging.getLogger()
handlers = root_logger.handlers
workflow_db_handler = None

for handler in handlers:
# should be always the second
if isinstance(handler, WorkflowDBHandler):
workflow_db_handler = handler
break

if workflow_db_handler:
self.logger.info("Pushing logs to DB")
workflow_db_handler.push_logs_to_db()
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.9"
version = "0.34.0"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down

0 comments on commit bd59e8b

Please sign in to comment.