Skip to content

Commit

Permalink
Fix Telemetry local function warning
Browse files Browse the repository at this point in the history
When a local function (meaning, either an anonymous function, or
a capture of a function without the module being specified) is
passed as an event handler to `:telemetry.attach/4` on Telemetry
version 1.0.0, it produces a warning about the performance penalty
of doing so, due to how these functions are handled by the Erlang
VM.

This commit changes the event handler function passed to
`:telemetry.attach/4` so that the module is specified in the
function capture.
  • Loading branch information
unflxw committed Dec 1, 2021
1 parent 1007817 commit ad0b00f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changesets/fix-telemetry-local-function-warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "fix"
---

Suppress a warning emitted by Telemetry 1.0.0, regarding the performance penalty of using local functions as event handlers, by specifying the module of the captured function.
2 changes: 1 addition & 1 deletion lib/appsignal/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Appsignal.Ecto do
def attach(otp_app, repo) do
event = telemetry_prefix(otp_app, repo) ++ [:query]

case :telemetry.attach({__MODULE__, event}, event, &handle_event/4, :ok) do
case :telemetry.attach({__MODULE__, event}, event, &__MODULE__.handle_event/4, :ok) do
:ok ->
Appsignal.Logger.debug("Appsignal.Ecto attached to #{inspect(event)}")

Expand Down

0 comments on commit ad0b00f

Please sign in to comment.