Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/logflare/auth/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ defmodule Logflare.Auth.Cache do
require Cachex.Spec

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -23,7 +21,7 @@ defmodule Logflare.Auth.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/backends/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ defmodule Logflare.Backends.Cache do
import Cachex.Spec

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -20,7 +18,7 @@ defmodule Logflare.Backends.Cache do
],
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/billing/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defmodule Logflare.Billing.Cache do
require Logger

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -18,7 +16,7 @@ defmodule Logflare.Billing.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/endpoints/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defmodule Logflare.Endpoints.Cache do
alias Logflare.Utils

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -18,7 +16,7 @@ defmodule Logflare.Endpoints.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.reject(&is_nil/1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/logs/log_events_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ defmodule Logflare.Logs.LogEvents.Cache do
@cache __MODULE__

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
name: __MODULE__,
Expand All @@ -21,7 +19,7 @@ defmodule Logflare.Logs.LogEvents.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(15_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/logs/rejected_log_events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ defmodule Logflare.Logs.RejectedLogEvents do
@cache __MODULE__

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: @cache,
start:
Expand All @@ -42,7 +40,7 @@ defmodule Logflare.Logs.RejectedLogEvents do
expiration: Utils.cache_expiration_min(60),
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(10_000)
]
|> Enum.filter(& &1)
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/partners/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defmodule Logflare.Partners.Cache do
alias Logflare.Utils

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -18,7 +16,7 @@ defmodule Logflare.Partners.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/pubsub_rates/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ defmodule Logflare.PubSubRates.Cache do
@default_bucket_width 60

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -21,7 +19,7 @@ defmodule Logflare.PubSubRates.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/rules/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ defmodule Logflare.Rules.Cache do
@behaviour ContextCache

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start: {
Expand All @@ -26,7 +24,7 @@ defmodule Logflare.Rules.Cache do
],
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/saved_searches/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defmodule Logflare.SavedSearches.Cache do
alias Logflare.Utils

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -18,7 +16,7 @@ defmodule Logflare.SavedSearches.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(10_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/source_schemas/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ defmodule Logflare.SourceSchemas.Cache do
import Cachex.Spec

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -24,7 +22,7 @@ defmodule Logflare.SourceSchemas.Cache do
],
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/sources/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ defmodule Logflare.Sources.Cache do
import Cachex.Spec

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -24,7 +22,7 @@ defmodule Logflare.Sources.Cache do
],
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
74 changes: 0 additions & 74 deletions lib/logflare/system_metrics/cachex/poller.ex

This file was deleted.

5 changes: 0 additions & 5 deletions lib/logflare/system_metrics/observer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ defmodule Logflare.SystemMetrics.Observer do
observer_metrics = get_metrics()
mem_metrics = get_memory()

Logger.info("Observer metrics!",
observer_metrics: observer_metrics,
observer_memory: mem_metrics
)

:telemetry.execute([:logflare, :system, :observer, :metrics], observer_metrics)
:telemetry.execute([:logflare, :system, :observer, :memory], mem_metrics)
end
Expand Down
13 changes: 10 additions & 3 deletions lib/logflare/system_metrics/schedulers/poller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ defmodule Logflare.SystemMetrics.Schedulers.Poller do
scheduler_metrics =
Schedulers.scheduler_utilization(last_scheduler_metrics, current_scheduler_metrics)

if Application.get_env(:logflare, :env) == :prod do
Logger.info("Scheduler metrics!", scheduler_metrics: scheduler_metrics)
end
Enum.each(scheduler_metrics, fn metric ->
:telemetry.execute(
[:logflare, :system, :scheduler, :utilization],
%{
utilization: metric.utilization,
utilization_percentage: metric.utilization_percentage
},
%{name: metric.name, type: metric.type}
)
end)

poll_metrics()
{:noreply, current_scheduler_metrics}
Expand Down
8 changes: 4 additions & 4 deletions lib/logflare/system_metrics/schedulers/schedulers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ defmodule Logflare.SystemMetrics.Schedulers do
defp formatter(scheduler_utilization) do
Enum.map(scheduler_utilization, fn x ->
case x do
{type, scheduler_name, utilization, utilization_percentage} ->
{type, scheduler_name, utilization, _utilization_percentage} ->
%{
name: Integer.to_string(scheduler_name),
type: rename_type(type),
utilization: Kernel.floor(utilization * 100),
utilization_percentage: utilization_percentage
utilization_percentage: utilization * 100
}

{_total, utilization, utilization_percentage} ->
{_total, utilization, _utilization_percentage} ->
%{
name: "total",
type: "total",
utilization: Kernel.floor(utilization * 100),
utilization_percentage: utilization_percentage
utilization_percentage: utilization * 100
}
end
end)
Expand Down
1 change: 0 additions & 1 deletion lib/logflare/system_metrics/system_metrics_sup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ defmodule Logflare.SystemMetricsSup do
SystemMetrics.AllLogsLogged,
SystemMetrics.AllLogsLogged.Poller,
SystemMetrics.Schedulers.Poller,
SystemMetrics.Cachex.Poller,
# telemetry poller
{
:telemetry_poller,
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/team_users/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defmodule Logflare.TeamUsers.Cache do
alias Logflare.Utils

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -18,7 +16,7 @@ defmodule Logflare.TeamUsers.Cache do
[
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
4 changes: 1 addition & 3 deletions lib/logflare/users/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ defmodule Logflare.Users.Cache do
import Cachex.Spec

def child_spec(_) do
stats = Application.get_env(:logflare, :cache_stats, false)

%{
id: __MODULE__,
start:
Expand All @@ -22,7 +20,7 @@ defmodule Logflare.Users.Cache do
],
hooks:
[
if(stats, do: Utils.cache_stats()),
Utils.cache_stats(),
Utils.cache_limit(100_000)
]
|> Enum.filter(& &1),
Expand Down
Loading
Loading