opencensus_plug v0.3.0 Opencensus.Plug.Metrics

Template method for creating Plug to measure response times.

Usage

  1. Create your own Plug module:
  defmodule MyApp.MetricsPlug do
    use Opencensus.Plug.Metrics
  end
  1. Add it to your pipeline, ex. for Phoenix:
  defmodule MyAppWeb.Endpoint do
    use Phoenix.Endpoint, otp_app: :my_app

    plug MyApp.MetricsPlug
  end

Configuration

use accepts prefix option that will be prefix of all measurements.

And also you can use attributes argument in use which must be either list of attributes which are names of 1-argument functions in current module that must return string value of the attribute, or map/keyword list of one of:

  • atom - which is name of the called function
  • {module, function} - which will call apply(module, function, [conn])
  • {module, function, args} - which will prepend conn to the given arguments and call apply(module, function, [conn | args])

Measurements

  • "#{prefix}/request" - duration of requests in microseconds