-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Easy] Improved Logging & Alerting (#175)
Redirects are now split into COW and ETH (with ETH Redirects being equivalent to grouped positive slippage). This also fixes the issue that the redirect message was exceeding max character limit for a single slack message and will now fit again into a "code block" (cf attached screenshots) 2. We now include both the +ve and -ve totals in the "Totals" summary
- Loading branch information
Showing
6 changed files
with
79 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Basic Slack Post functionality. Sends a message thread to a specified channel. | ||
""" | ||
from slack.web.client import WebClient | ||
from slack.web.slack_response import SlackResponse | ||
|
||
|
||
def post_to_slack( | ||
slack_client: WebClient, channel: str, message: str, sub_messages: dict[str, str] | ||
) -> None: | ||
"""Posts message to Slack channel and sub message inside thread of first message""" | ||
response = slack_client.chat_postMessage( | ||
channel=channel, | ||
text=message, | ||
# Do not show link preview! | ||
# https://api.slack.com/reference/messaging/link-unfurling | ||
unfurl_media=False, | ||
) | ||
# This assertion is only for type safety, | ||
# since previous function can also return a Future | ||
assert isinstance(response, SlackResponse) | ||
# Post logs in thread. | ||
for category, log in sub_messages.items(): | ||
slack_client.chat_postMessage( | ||
channel=channel, | ||
format="mrkdwn", | ||
text=f"{category}:\n```{log}```", | ||
# According to https://api.slack.com/methods/conversations.replies | ||
thread_ts=response.get("ts"), | ||
unfurl_media=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters