scoutapp / scout_apm_elixir

ScoutAPM Elixir Agent. Supports Phoenix and other frameworks.
https://scoutapm.com
Other
36 stars 20 forks source link

Module attributes fail when instrumenting functions of the same name #34

Closed itsderek23 closed 7 years ago

itsderek23 commented 7 years ago

For example:

  @transaction(type: "web", name: "new_msg")
  def handle_in("new_msg", %{"body" => body}, socket) do
    broadcast! socket, "new_msg", %{body: body}
    {:noreply, socket}
  end

  @transaction(type: "web", name: "new_msg2")
  def handle_in("new_msg2", %{"body" => body}, socket) do
    broadcast! socket, "new_msg", %{body: body}
    {:noreply, socket}
  end

Results in a compile error:

== Compilation error on file lib/camp_waitlist/web/channels/HtmlChannel.ex ==
** (ArgumentError) cannot make function handle_in/3 overridable because it was not defined
    (elixir) lib/module.ex:804: anonymous fn/2 in Module.make_overridable/2
    (stdlib) lists.erl:1338: :lists.foreach/2
    lib/scout_apm/tracing/annotations.ex:79: anonymous fn/2 in ScoutApm.Tracing.Annotations.instrument_transactions/1
    (elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1229: Enum."-map/2-lists^map/1-0-"/2
    expanding macro: ScoutApm.Tracing.Annotations.before_compile/1
    lib/camp_waitlist/web/channels/HtmlChannel.ex:1: CampWaitlist.Web.HtmlChannel (module)
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
itsderek23 commented 7 years ago

@cschneid - sounds like you might have some ideas on this. I've re-assigned this to you for now.

cschneid commented 7 years ago

First half is fixed in #36

cschneid commented 7 years ago

Err - nevermind about "first half". The PR fixes this.