diff --git a/config/config.exs b/config/config.exs index 9c063d7..595f934 100644 --- a/config/config.exs +++ b/config/config.exs @@ -74,7 +74,6 @@ config :logger, :console, config :phoenix, :json_library, Jason config :logflare_logger_backend, - url: "https://api.logflare.app", flush_interval: 1_000, max_batch_size: 50, metadata: :all diff --git a/config/runtime.exs b/config/runtime.exs index c86d2cf..bbb1bea 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,5 +1,8 @@ import Config +config :logflare_logger_backend, + url: System.get_env("LOGFLARE_LOGGER_BACKEND_URL", "https://api.logflare.app") + if config_env() == :prod do secret_key_base = System.get_env("SECRET_KEY_BASE") || diff --git a/lib/realtime/monitoring/prom_ex.ex b/lib/realtime/monitoring/prom_ex.ex index dad5b98..2d8ec80 100644 --- a/lib/realtime/monitoring/prom_ex.ex +++ b/lib/realtime/monitoring/prom_ex.ex @@ -3,8 +3,6 @@ defmodule Realtime.PromEx do import Realtime.Helpers, only: [short_node_id: 0] - import Realtime.Helpers, only: [short_node_id: 0] - @moduledoc """ Be sure to add the following to finish setting up PromEx: diff --git a/lib/realtime/monitoring/prom_ex/plugins/tenant.ex b/lib/realtime/monitoring/prom_ex/plugins/tenant.ex index 756954c..c121faf 100644 --- a/lib/realtime/monitoring/prom_ex/plugins/tenant.ex +++ b/lib/realtime/monitoring/prom_ex/plugins/tenant.ex @@ -82,7 +82,7 @@ defmodule Realtime.PromEx.Plugins.Tenant do measurement: :duration, description: "Duration of the logical replication slot polling query for Realtime RLS.", tags: [:tenant], - unit: {:native, :millisecond}, + unit: {:microsecond, :millisecond}, reporter_options: [ buckets: [125, 250, 500, 1_000, 2_000, 4_000, 8_000, 16_000, 32_000, 64_000] ] diff --git a/lib/realtime_web/channels/realtime_channel.ex b/lib/realtime_web/channels/realtime_channel.ex index f43eba0..65d0cfc 100644 --- a/lib/realtime_web/channels/realtime_channel.ex +++ b/lib/realtime_web/channels/realtime_channel.ex @@ -144,8 +144,6 @@ defmodule RealtimeWeb.RealtimeChannel do {UUID.string_to_binary!(id), :erlang.phash2(params)} end - IO.inspect(topic, label: "CHANNEL TOPIC") - metadata = [ metadata: {:subscriber_fastlane, transport_pid, serializer, ids, topic, tenant, is_new_api} @@ -237,22 +235,7 @@ defmodule RealtimeWeb.RealtimeChannel do def handle_info(:sync_presence, %{assigns: %{tenant_topic: topic}} = socket) do socket = count(socket) - presence_list = - socket - |> presence_list_shard_bypass() - |> case do - {:ok, [_ | _]} -> - Presence.list(topic) - - {:ok, []} -> - %{} - - {:error, message} -> - Logger.error("Unable to fetch Presence list for topic #{topic}: #{message}") - Presence.list(topic) - end - - push(socket, "presence_state", presence_list) + push(socket, "presence_state", presence_dirty_list(topic)) {:noreply, socket} end @@ -653,17 +636,13 @@ defmodule RealtimeWeb.RealtimeChannel do }) end - defp presence_list_shard_bypass(%{assigns: %{tenant_topic: topic}} = _socket) do - try do - [{:pool_size, size}] = :ets.lookup(Presence, :pool_size) + def presence_dirty_list(topic) do + [{:pool_size, size}] = :ets.lookup(Presence, :pool_size) - {:ok, - Presence - |> Shard.name_for_topic(topic, size) - |> Shard.dirty_list(topic)} - rescue - e -> {:error, Exception.message(e)} - end + Presence + |> Shard.name_for_topic(topic, size) + |> Shard.dirty_list(topic) + |> Phoenix.Presence.group() end defp start_db_rate_counter(tenant) do diff --git a/mix.exs b/mix.exs index cf4b403..7c2b0a2 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do def project do [ app: :realtime, - version: "2.9.0", + version: "2.9.4", elixir: "~> 1.14.0", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod,