From b59111e4a6329b02a80711d3bf64f217b9063180 Mon Sep 17 00:00:00 2001 From: Ori Kotek Date: Mon, 12 Aug 2024 16:10:41 +0300 Subject: [PATCH] Add app_name to log_context in Bitbucket and GitLab webhook handlers --- pr_agent/servers/bitbucket_app.py | 3 ++- pr_agent/servers/gitlab_webhook.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pr_agent/servers/bitbucket_app.py b/pr_agent/servers/bitbucket_app.py index a0104cf06..634b48bf8 100644 --- a/pr_agent/servers/bitbucket_app.py +++ b/pr_agent/servers/bitbucket_app.py @@ -93,7 +93,8 @@ async def _perform_commands_bitbucket(commands_conf: str, agent: PRAgent, api_ur @router.post("/webhook") async def handle_github_webhooks(background_tasks: BackgroundTasks, request: Request): - log_context = {"server_type": "bitbucket_app"} + app_name = get_settings().get("CONFIG.APP_NAME", "Unknown") + log_context = {"server_type": "bitbucket_app", "app_name": app_name} get_logger().debug(request.headers) jwt_header = request.headers.get("authorization", None) if jwt_header: diff --git a/pr_agent/servers/gitlab_webhook.py b/pr_agent/servers/gitlab_webhook.py index e81044b8e..2c525858a 100644 --- a/pr_agent/servers/gitlab_webhook.py +++ b/pr_agent/servers/gitlab_webhook.py @@ -51,6 +51,7 @@ async def handle_request(api_url: str, body: str, log_context: dict, sender_id: log_context["action"] = body log_context["event"] = "pull_request" if body == "/review" else "comment" log_context["api_url"] = api_url + log_context["app_name"] = get_settings().get("CONFIG.APP_NAME", "Unknown") with get_logger().contextualize(**log_context): await PRAgent().handle_request(api_url, body)