Skip to content

Commit

Permalink
Merge pull request #1599 from Logflare/staging
Browse files Browse the repository at this point in the history
Release v1.3.15
  • Loading branch information
filipecabaco authored Jun 21, 2023
2 parents fc73736 + 4ef762e commit a4b5887
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 21 deletions.
Binary file modified .staging.cacert.key.enc
Binary file not shown.
Binary file modified .staging.cacert.pem.enc
Binary file not shown.
Binary file modified .staging.cert.key.enc
Binary file not shown.
Binary file modified .staging.cert.pem.enc
Binary file not shown.
Binary file modified .staging.env.enc
Binary file not shown.
1 change: 1 addition & 0 deletions .template.env
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ TWILLIO_AUTH_TOKEN=
STRIPE_API_KEY=
STRIPE_PUBLISHABLE_KEY=
LOGFLARE_GRPC_PORT=
LOGFLARE_CACHE_STATS=
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.14
1.3.15
3 changes: 2 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ config :logflare,
config_cat_sdk_key: System.get_env("LOGFLARE_CONFIG_CAT_SDK_KEY"),
single_tenant: System.get_env("LOGFLARE_SINGLE_TENANT"),
supabase_mode: System.get_env("LOGFLARE_SUPABASE_MODE"),
api_key: System.get_env("LOGFLARE_API_KEY")
api_key: System.get_env("LOGFLARE_API_KEY"),
cache_stats: System.get_env("LOGFLARE_CACHE_STATS", "false") == "true"
]
|> filter_nil_kv_pairs.()

Expand Down
Binary file modified gcloud_staging.json.enc
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/logflare/billing/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ defmodule Logflare.Billing.Cache do
require Logger

def child_spec(_) do
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: true, limit: 100_000]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: stats, limit: 100_000]]}}
end

def get_billing_account_by(keyword) do
Expand Down
3 changes: 2 additions & 1 deletion lib/logflare/context_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ defmodule Logflare.ContextCache do
@cache __MODULE__

def child_spec(_) do
%{id: __MODULE__, start: {Cachex, :start_link, [@cache, [stats: true]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: __MODULE__, start: {Cachex, :start_link, [@cache, [stats: stats]]}}
end

def apply_fun(context, {fun, arity}, args) do
Expand Down
4 changes: 3 additions & 1 deletion lib/logflare/logs/log_events_cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ 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 @@ -17,7 +19,7 @@ defmodule Logflare.Logs.LogEvents.Cache do
:start_link,
[
@cache,
[expiration: expiration(default: @ttl), limit: limit(size: 10_000), stats: true]
[expiration: expiration(default: @ttl), limit: limit(size: 10_000), stats: stats]
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/logflare/logs/rejected_log_events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ defmodule Logflare.Logs.RejectedLogEvents do
@cache __MODULE__

def child_spec(_) do
%{id: @cache, start: {Cachex, :start_link, [@cache, [limit: 10_000, stats: true]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: @cache, start: {Cachex, :start_link, [@cache, [limit: 10_000, stats: stats]]}}
end

@spec get_by_source(Source.t()) :: list(LE.t())
Expand Down
3 changes: 2 additions & 1 deletion lib/logflare/pubsub_rates/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ defmodule Logflare.PubSubRates.Cache do
@default_bucket_width 60

def child_spec(_) do
%{id: __MODULE__, start: {Cachex, :start_link, [@cache, [stats: true]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: __MODULE__, start: {Cachex, :start_link, [@cache, [stats: stats]]}}
end

def cache_rates(source_id, rates) when is_atom(source_id) do
Expand Down
3 changes: 2 additions & 1 deletion lib/logflare/source_schemas/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ defmodule Logflare.SourceSchemas.Cache do
alias Logflare.SourceSchemas

def child_spec(_) do
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: true, limit: 100_000]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: stats, limit: 100_000]]}}
end

def get_source_schema(id), do: apply_fun(__ENV__.function, [id])
Expand Down
3 changes: 2 additions & 1 deletion lib/logflare/sources/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ defmodule Logflare.Sources.Cache do
alias Logflare.Sources

def child_spec(_) do
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: true, limit: 100_000]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: stats, limit: 100_000]]}}
end

# For ingest
Expand Down
3 changes: 2 additions & 1 deletion lib/logflare/users/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ defmodule Logflare.Users.Cache do
alias Logflare.Users

def child_spec(_) do
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: true, limit: 100_000]]}}
stats = Application.get_env(:logflare, :cache_stats, false)
%{id: __MODULE__, start: {Cachex, :start_link, [__MODULE__, [stats: stats, limit: 100_000]]}}
end

def get_by(keyword), do: apply_repo_fun(__ENV__.function, [keyword])
Expand Down
34 changes: 23 additions & 11 deletions lib/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,23 @@ defmodule Logflare.Telemetry do
end

def metrics do
cache_stats? = Application.get_env(:logflare, :cache_stats, false)

cache_metrics =
Enum.flat_map(@caches, fn {_cache, metric} ->
[
last_value("cachex.#{metric}.purge"),
last_value("cachex.#{metric}.stats"),
last_value("cachex.#{metric}.evictions"),
last_value("cachex.#{metric}.expirations"),
last_value("cachex.#{metric}.operations"),
last_value("cachex.#{metric}.total_heap_size", unit: {:byte, :megabyte})
]
end)
if cache_stats? do
Enum.flat_map(@caches, fn {_cache, metric} ->
[
last_value("cachex.#{metric}.purge"),
last_value("cachex.#{metric}.stats"),
last_value("cachex.#{metric}.evictions"),
last_value("cachex.#{metric}.expirations"),
last_value("cachex.#{metric}.operations"),
last_value("cachex.#{metric}.total_heap_size", unit: {:byte, :megabyte})
]
end)
else
[]
end

phoenix_metrics = [
summary("phoenix.endpoint.stop.duration", unit: {:native, :millisecond}),
Expand Down Expand Up @@ -67,7 +73,13 @@ defmodule Logflare.Telemetry do
end

defp periodic_measurements() do
[{__MODULE__, :cachex_metrics, []}]
cache_stats? = Application.get_env(:logflare, :cache_stats, false)

if cache_stats? do
[{__MODULE__, :cachex_metrics, []}]
else
[]
end
end

def cachex_metrics do
Expand Down

0 comments on commit a4b5887

Please sign in to comment.