View Source PromEx.Plugins.PlugCowboy (PromEx v1.9.0)

This plugin captures HTTP request metrics emitted by Plug.Cowboy.

This plugin exposes the following metric group:

  • :plug_cowboy_http_event_metrics

plugin-options

Plugin options

  • routers: Required This is a list with the full module names of your Routers (e.g MyAppWeb.Router). Phoenix and Plug routers are supported. When the Phoenix dependency is present in your project, a list of Phoenix Routers is expected. Otherwise a list of Plug.Router modules must be provided

  • event_prefix: Optional, allows you to set the event prefix for the Telemetry events.

  • metric_prefix: This option is OPTIONAL and is used to override the default metric prefix of [otp_app, :prom_ex, :plug_cowboy]. If this changes you will also want to set plug_cowboy_metric_prefix in your dashboard_assigns to the snakecase version of your prefix, the default plug_cowboy_metric_prefix is {otp_app}_prom_ex_plug_cowboy.

  • duration_unit: This is an OPTIONAL option and is a Telemetry.Metrics.time_unit(). It can be one of: :second | :millisecond | :microsecond | :nanosecond. It is :millisecond by default.

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.PlugCowboy, routers: [MyApp.Router]}
    ]
  end

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

To ignore certain paths, pass a list of routes using the :ignore_routes option

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

  @impl true
  def plugins do
    [
      ...
      {PromEx.Plugins.PlugCowboy, routers: [MyApp.Router], ignore_routes: ["/metrics"]}
    ]
  end

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