serokell / tzbot

Timezone bot for Slack
Mozilla Public License 2.0
7 stars 2 forks source link

Enhance `MessageContext` #109

Closed dcastro closed 1 year ago

dcastro commented 1 year ago

Clarification and motivation

The MessageContext data type adds a message_id label to log messages, so we can identify which Slack message the server was processing when the log event occurred.

https://github.com/serokell/tzbot/blob/4c2315ea7dc3a32248e83cb48ee6c6c17569e099/src/TzBot/Logger.hs#L73-L74

Example log message:

Sep 06 16:46:45 tejat-prior tzbot-start[3253022]: [2023-09-06 16:46:45][TzBot.main.message][Warning][tejat-prior][PID 3253022][ThreadId 5][event_id:4f157b7a-1794-4fc1-aa24-896013a4f9d9][event_type:message][message_id:1694018804.258029][tzbot-1.0-LVFLUoOnjh5IWnKa9LirCj:TzBot.ProcessEvents.Common src/TzBot/ProcessEvents/Common.hs:105:9] Unknown level2 block types: [emoji]

However, a message ID (or message timestamp, really) is not enough to identify a message. A message is uniquely identified by the (timestamp, channel_id) pair.

Therefore, MessageContext should also add a channel_id label.