Skip to content

Commit a1cedb2

Browse files
committed
add debug logs for getting messages
1 parent c5bd1c3 commit a1cedb2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/robusta/integrations/receiver.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ def __exec_external_request(self, action_request: ExternalActionRequest, validat
208208

209209
if sync_response:
210210
http_code = 200 if response.get("success") else 500
211+
logging.debug(
212+
f"Sending results for `{action_request.body.action_name}` {to_safe_str(action_request.body.action_params)} - {http_code}")
211213
self.ws.send(data=json.dumps(self.__sync_response(http_code, action_request.request_id, response)))
214+
logging.debug(
215+
f"After Sending results for `{action_request.body.action_name}` {to_safe_str(action_request.body.action_params)} - {http_code}")
212216

213217
def __exec_external_stream_request(self, action_request: ExternalActionRequest, validate_timestamp: bool):
214218
logging.debug(f"Callback `{action_request.body.action_name}` {to_safe_str(action_request.body.action_params)}")
@@ -225,7 +229,11 @@ def __exec_external_stream_request(self, action_request: ExternalActionRequest,
225229
action_request.body.action_params,
226230
lambda data: self.__stream_response(request_id=action_request.request_id, data=data))
227231
res = "" if res.get("success") else f"event: error\ndata: {json.dumps(res)}\n\n"
232+
233+
logging.debug(f"Stream Sending result `{action_request.body.action_name}` {to_safe_str(action_request.body.action_params)} - {res}")
228234
self.__close_stream_response(action_request.request_id, res)
235+
logging.debug(
236+
f"After Stream Sending result `{action_request.body.action_name}` {to_safe_str(action_request.body.action_params)} - {res}")
229237

230238
def _process_action(self, action: ExternalActionRequest, validate_timestamp: bool) -> None:
231239
self._executor.submit(self._process_action_sync, action, validate_timestamp)
@@ -284,12 +292,18 @@ def on_message(self, ws: websocket.WebSocketApp, message: str) -> None:
284292
return
285293

286294
if isinstance(incoming_event, SlackActionsMessage):
295+
logging.debug(
296+
f"on_message got Slack callback: {len(incoming_event.actions)} action(s) from "
297+
f"user={incoming_event.user.username if incoming_event.user else 'unknown'}"
298+
)
287299
# slack callbacks have a list of 'actions'. Within each action there a 'value' field,
288300
# which container the actual action details we need to run.
289301
# This wrapper format is part of the slack API, and cannot be changed by us.
290302
for slack_action_request in incoming_event.actions:
291303
self._process_action(slack_action_request.value, validate_timestamp=False)
292304
else:
305+
logging.debug(
306+
f"on_message got external action request: `{incoming_event.body.action_name}` {to_safe_str(incoming_event.body.action_params)}")
293307
self._process_action(incoming_event, validate_timestamp=True)
294308

295309
@staticmethod

0 commit comments

Comments
 (0)