Skip to content

Commit

Permalink
fix: global logs homepage tweak (#2235)
Browse files Browse the repository at this point in the history
* fix: add timeout to multi_call

* fix: don't pull global count on each pageview
  • Loading branch information
chasers authored Oct 23, 2024
1 parent 19e58e0 commit 8891916
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/logflare/system_metrics/all_logs_logged/poller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule Logflare.SystemMetrics.AllLogsLogged.Poller do
use GenServer
alias Logflare.Repo
alias Logflare.SystemMetric
alias Logflare.Cluster

require Logger

Expand All @@ -15,7 +16,8 @@ defmodule Logflare.SystemMetrics.AllLogsLogged.Poller do
end

def get_logs_per_second_cluster() do
{success, _failed} = GenServer.multi_call(__MODULE__, :logs_last_second)
{success, _failed} =
GenServer.multi_call(Cluster.Utils.node_list_all(), __MODULE__, :logs_last_second, 5_000)

for {_node, count} <- success do
count
Expand Down
9 changes: 8 additions & 1 deletion lib/logflare_web/live/global_log_metrics_lv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ defmodule LogflareWeb.GlobalLogMetricsLV do
def mount(_params, _session, socket) do
if connected?(socket), do: :timer.send_interval(1_000, self(), :tick)

{:ok, put_data(socket)}
# TODO should subscribe to these data with PubSub instead

socket =
socket
|> assign(:log_count, 0)
|> assign(:per_second, 0)

{:ok, socket}
end

def handle_info(:tick, socket) do
Expand Down

0 comments on commit 8891916

Please sign in to comment.