Skip to content

OpenCensus instrumentation for the Phoenix framework

Notifications You must be signed in to change notification settings

moosecodebv/opencensus_phoenix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpencensusPhoenix

CircleCI Hex version badge

Phoenix has abandoned instrumenters in 1.5 in favour of the :telemetry library. The following approach should work with all versions of Phoenix.

Simply ensure that the following code runs while your app is starting up (eg, in the Application.start/2 callback):

# lib/my_app_web/endpoint.ex check this file for the event_prefix
defmodule MyAppWeb.Endpoint do
  ...
  plug Plug.Telemetry, event_prefix: [:my_app, :endpoint]
  ...
end

# lib/my_app/application.ex, add this line using event_prefix from above:
def start(_type, _args) do
  ...
  OpencensusPhoenix.Telemetry.setup()
  ...
end

Phoenix <=1.4 only

Phoenix instrumenter callback module to automatically create OpenCensus spans for Phoenix Controller and View information.

Simply configure your Phoenix Endpoint to use this library as one of its instrumenters:

config :my_app, MyAppWeb.Endpoint,
  # ... existing config ...
  instrumenters: [OpencensusPhoenix.Instrumenter]

Resource Names

Prior to Phoenix 1.4, the "route info" was not available to plugs. As such instead of using the http route as the resource name, we use the controller + action combination. For example:

  • Pre 1.4: MyApp.Posts.index
  • Version 1.4 or greater: /posts

About

OpenCensus instrumentation for the Phoenix framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%