Skip to content

Commit

Permalink
add tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
RudolfMan committed Apr 17, 2022
1 parent e834438 commit efb4cea
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/acme_web/live/order_live/show.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
defmodule AcmeWeb.OrderLive.Show do
use AcmeWeb, :live_view

require OpenTelemetry.Tracer

alias Acme.Orders

@impl true
Expand All @@ -20,7 +22,14 @@ defmodule AcmeWeb.OrderLive.Show do

@impl true
def handle_info({:order_updated, order}, socket) do
{:noreply, assign(socket, :order, order)}
opts = %{attributes: %{user: inspect(self())}}

OpenTelemetry.Tracer.with_span "order_live.show:order_updated", opts do
# expensive operation like DB call, service call.. etc.
Process.sleep(70)

{:noreply, assign(socket, :order, order)}
end
end

defp page_title(:show), do: "Show Order"
Expand Down

0 comments on commit efb4cea

Please sign in to comment.