Exampple.Router.Task.Monitor (exampple v0.7.2)

The monitor starts a task to attend the incoming request, when the task is launched a timer is set. The timer is cancelled when the task is terminated. If the task crashes, the monitor receives a message and replies with an error. In case of timeout the request is returning a timeout and the task is terminated.

In addition to the logs regarding the stanzas we have the following information to be gathered by telemetry:

  • [:xmpp, :request, :success]
  • [:xmpp, :request, :failure]
  • [:xmpp, :request, :timeout]

All of them register duration in milliseconds so, you can get the maximum, minimum, average, percentile and more statistics from the duration of the stanzas inside of the system based on if they are correct (success), wrong (failure) or was not attended (timeout).

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the monitor as a server passing the stanza in xmlel format, the XMPP domain for the component and the name of the application (otp_app) and the timeout, all of those parameters as a list.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

start_link(list)

Starts the monitor as a server passing the stanza in xmlel format, the XMPP domain for the component and the name of the application (otp_app) and the timeout, all of those parameters as a list.

The timeout is needed to know where we have to terminate the task and annotate this kind of failure.