Skip to content

Resolve "count messages when sent"

aguestuser requested to merge 58-count-messages-when-sent into master

Closes #58 (closed)

This MR nominally adds rudimentary metric-tracking (counters for commands received / command responses sent / broadcast messages received / broadcast messages sent). It does this, but in so doing also accomplishes a fairly substantial refactor of how commands are processed and messages formatted.

Notable changes include:

  • perform eager-loading of all nested channel resources (administrations and subscriptions) when each message arrives, such that these lookups are not required either for metric logging or broadcast sending (both of which must have knowledge of subscriber counts or actual phone numbers) or info command handling (must have knowledge of admin/sub counts and numbers).
  • introduce a UNAUTHORIZED status and set of messages to distinguish from other kinds of error
  • modify how message formatting works: extract all messages to a dispatcher/messages.js file, flatten their heircharchy, and infer whether messages should be prefixed or not by passing commandResult (now including a command field) along with dispatchable along to the messenger service, and inspecting the command and status for whether or not message should be prefixed (UNAUTHORIZED statuses and RENAME command responses are not prefixed)

Also, to help @zig with #39 (closed) , we leave some TODOs where future prometheus hooks should go, both for incrementing message-sent counters and for counting monitoring-worth errors.

Merge request reports