opencensus_plug v0.3.0 Opencensus.Plug.Trace behaviour

Template method for creating Plug to trace your Plug requests.

Usage

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

    plug MyApp.TracingPlug
  end

Configuration

This module creates 2 callback modules, which allows you to configure your span and also provides a way to add custom attributes assigned to span.

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])

Example:

defmodule MyAppWeb.TraceWithCustomAttribute do
  use Opencensus.Plug.Trace, attributes: [:method]

  def method(conn), do: conn.method
end

Link to this section Summary

Callbacks

Return name for current span. By defaut returns "plug"

Return tuple containing span status and message. By default return value status assigned by default mapping and empty message

Link to this section Callbacks

Link to this callback

span_name(arg0, options)
span_name(Plug.Conn.t(), options :: term()) :: String.t()

Return name for current span. By defaut returns "plug"

Link to this callback

span_status(arg0, options)
span_status(Plug.Conn.t(), options :: term()) :: {integer(), String.t()}

Return tuple containing span status and message. By default return value status assigned by default mapping and empty message.