View Source PromEx.Plugins.Absinthe (PromEx v1.10.0)

This plugin captures metrics emitted by Absinthe. Specifically, it captures timings and metrics around execution times, query complexity, and subscription timings. In order to get complexity metrics you'll need to make sure that you have :analyze_complexity enabled in Absinthe.Plug. This plugin can generate a large amount of Prometheus series, so it is suggested that you use the ignored_entrypoints and only_entrypoints (TODO: coming soon) options to prune down the resulting metrics if needed.

This plugin supports the following options:

  • ignored_entrypoints: This option is OPTIONAL and is used to filter out Absinthe GraphQL schema entrypoints that you do not want to track metrics for. For example, if you don't want metrics on the :__schema entrypoint (used for GraphQL schema introspection), you would set a value of [:__schema]. This is applicable to queries, mutations, and subscriptions.

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

  • 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.

This plugin exposes the following metric groups:

  • :absinthe_execute_event_metrics
  • :absinthe_subscription_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.Absinthe, ignored_entrypoints: [:__schema]}
    ]
  end

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