View Source PromEx.Plugins.Broadway (PromEx v1.7.1)

This plugin captures metrics emitted by Broadway.

This plugin exposes the following metric groups:

  • :broadway_init_event_metrics
  • :broadway_message_event_metrics
  • :broadway_batch_event_metrics

To use plugin in your application, add the following to your PromEx module:

defmodule WebApp.PromEx do
  use PromEx, otp_app: :web_app

  @impl true
  def plugins do
    [
      ...
      PromEx.Plugins.Broadway
    ]
  end

  @impl true
  def dashboards do
    [
      ...
      {:prom_ex, "broadway.json"}
    ]
  end
end

To correctly capture per-message metrics and error rate, add the following transform to your pipeline:

defmodule WebApp.MyPipeline do
  use Broadway

  alias Broadway.Message

  def start_link(_opts) do
    Broadway.start_link(__MODULE__,
      name: __MODULE__,
      producer: [
        ...
        transformer: {__MODULE__, :transform, []}
      ]
    )
  end

  def transform(event, _opts) do
    %Message{
      data: event,
      acknowledger: {__MODULE__, :ack_id, :ack_data}
    }
  end
end