Skip to content

Commit

Permalink
Update Telemetry examples for LiveView socket connected? (phoenixfram…
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel authored Jan 23, 2023
1 parent f9139c5 commit 3364e9b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions guides/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ the previous example.
defp live_view_metric_tag_values(metadata) do
metadata
|> Map.put(:view, metadata.socket.view)
|> Map.put(:connected?, metadata.socket.connected?)
|> Map.put(:connected?, Phoenix.LiveView.connected?(metadata.socket))
end
```

Expand All @@ -435,11 +435,11 @@ convert the `connected?` boolean into human readable text.
defp live_view_metric_tag_values(metadata) do
metadata
|> Map.put(:view, inspect(metadata.socket.view))
|> Map.put(:connected?, get_connection_status(metadata.socket))
|> Map.put(:connected?, get_connection_status(Phoenix.LiveView.connected?(metadata.socket)))
end

defp get_connection_status(%{connected?: true}), do: "Connected"
defp get_connection_status(%{connected?: false}), do: "Disconnected"
defp get_connection_status(true), do: "Connected"
defp get_connection_status(false), do: "Disconnected"
```

Now the value label will be rendered like `"Phoenix.LiveDashboard.MetricsLive
Expand Down

0 comments on commit 3364e9b

Please sign in to comment.