AppSignal v1.2.1 Appsignal.Phoenix.Channel
Instrumentation for channel events
Instrumenting a channel’s handle_in/3
Currently, incoming channel requests can be instrumented, by adding
code to the handle_in
function of your application. We use
function decorators to
minimize the amount of code you have to add to your channel.
defmodule SomeApp.MyChannel do
use Appsignal.Instrumentation.Decorators
@decorate channel_action
def handle_in("ping", _payload, socket) do
# your code here..
end
end
Channel events will be displayed under the “Background jobs” tab, showing the channel module and the action argument that you entered.
Instrumenting without decorators
You can also decide not to use function decorators. In that case,
use the channel_action/3
function directly, passing in a name for
the channel action, the socket and the actual code that you are
executing in the channel handler:
defmodule SomeApp.MyChannel do
import Appsignal.Phoenix.Channel, only: [channel_action: 4]
def handle_in("ping" = action, _payload, socket) do
channel_action(__MODULE__, action, socket, fn ->
# do some heave processing here...
reply = perform_work()
{:reply, {:ok, reply}, socket}
end)
end
end
Summary
Functions
Record a channel action. Meant to be called from the ‘channel_action’ instrumentation decorator
Given the Appsignal.Transaction
and a Phoenix.Socket
, add the
socket metadata to the transaction
Functions
Record a channel action. Meant to be called from the ‘channel_action’ instrumentation decorator.
Given the Appsignal.Transaction
and a Phoenix.Socket
, add the
socket metadata to the transaction.