HareMq.Telemetry (hare_mq v1.4.0)

Copy Markdown

Telemetry events emitted by HareMq.

Attach handlers using :telemetry.attach/4 or :telemetry.attach_many/4.

Connection events

[:hare_mq, :connection, :connected]

Emitted when a broker connection is successfully opened.

KeyValue
measurements :system_timeSystem.system_time()
metadata :connection_nameRegistered process name (e.g. {:global, HareMq.Connection})
metadata :hostAMQP URL string

[:hare_mq, :connection, :disconnected]

Emitted when a monitored connection process goes down unexpectedly.

KeyValue
measurements :system_timeSystem.system_time()
metadata :connection_nameRegistered process name
metadata :reasonExit reason from the :DOWN message

[:hare_mq, :connection, :reconnecting]

Emitted whenever a reconnect attempt is scheduled (missing config or failed open).

KeyValue
measurements :retry_delay_msMilliseconds until next attempt
metadata :connection_nameRegistered process name
metadata :reason:missing_config or the connection error term

Consumer events

[:hare_mq, :consumer, :connected]

Emitted when a consumer channel is open and Basic.consume has been called.

KeyValue
measurements :system_timeSystem.system_time()
metadata :consumerConsumer module name
metadata :queueQueue name
metadata :exchangeExchange name
metadata :routing_keyRouting key
metadata :streamtrue for stream consumers

[:hare_mq, :consumer, :message, :start]

[:hare_mq, :consumer, :message, :stop]

[:hare_mq, :consumer, :message, :exception]

Emitted by :telemetry.span/3 around the user-supplied consume/1 callback. Start/stop/exception events follow the standard :telemetry.span contract.

Start metadata:

KeyValue
metadata :queueQueue name
metadata :exchangeExchange name
metadata :routing_keyRouting key

Stop measurements additionally include :duration (native time units). Stop metadata additionally includes :result (:ok or :error).

Publisher events

[:hare_mq, :publisher, :connected]

Emitted when a publisher channel is open and ready to publish.

KeyValue
measurements :system_timeSystem.system_time()
metadata :publisherPublisher module name
metadata :exchangeExchange name
metadata :routing_keyRouting key

[:hare_mq, :publisher, :message, :published]

Emitted after AMQP.Basic.publish/5 returns :ok.

KeyValue
measurements :system_timeSystem.system_time()
metadata :publisherPublisher module name
metadata :exchangeExchange name
metadata :routing_keyRouting key

[:hare_mq, :publisher, :message, :not_connected]

Emitted when publish_message/1 is called but no channel is available.

KeyValue
measurements :system_timeSystem.system_time()
metadata :publisherPublisher module name
metadata :exchangeExchange name
metadata :routing_keyRouting key

Retry publisher events

[:hare_mq, :retry_publisher, :message, :retried]

Emitted when a failed message is sent to a delay queue.

KeyValue
measurements :retry_countCurrent retry attempt number
measurements :system_timeSystem.system_time()
metadata :queueMain queue name
metadata :delay_queueTarget delay queue name

[:hare_mq, :retry_publisher, :message, :dead_lettered]

Emitted when a message has exceeded retry_limit and is sent to the dead-letter queue.

KeyValue
measurements :retry_countFinal retry count
measurements :system_timeSystem.system_time()
metadata :queueMain queue name
metadata :dead_queueDead-letter queue name

Example: attaching a simple logger handler

:telemetry.attach_many(
  "hare-mq-logger",
  [
    [:hare_mq, :connection, :connected],
    [:hare_mq, :connection, :disconnected],
    [:hare_mq, :consumer, :message, :stop],
    [:hare_mq, :retry_publisher, :message, :dead_lettered]
  ],
  fn event, measurements, metadata, _config ->
    require Logger
    Logger.info("[telemetry] #{inspect(event)} #{inspect(measurements)} #{inspect(metadata)}")
  end,
  nil
)