Skip to content

Commit

Permalink
Adjusts in metrics setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sleipnir committed Jan 21, 2023
1 parent 8001913 commit 92a5231
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/sidecar/metrics_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ defmodule Sidecar.MetricsSupervisor do
end

def init(config) do
children = if metrics_disabled?, do: [], else: get_metrics_supervisor_tree(config)
children = if config.proxy_disable_metrics, do: [], else: get_metrics_supervisor_tree(config)

Supervisor.init(children, strategy: :one_for_one)
end

defp get_metrics_supervisor_tree(config) do
if console_metrics_disabled? do
if config.proxy_console_metrics do
[
{:telemetry_poller, measurements: periodic_measurements(config)},
{TelemetryMetricsPrometheus.Core, name: :spawm_metrics, metrics: metrics()}
{TelemetryMetricsPrometheus.Core, name: :spawm_metrics, metrics: metrics()},
{Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
]
else
[
{:telemetry_poller, measurements: periodic_measurements(config)},
{TelemetryMetricsPrometheus.Core, name: :spawm_metrics, metrics: metrics()},
{Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
{TelemetryMetricsPrometheus.Core, name: :spawm_metrics, metrics: metrics()}
]
end
end
Expand Down Expand Up @@ -59,9 +59,4 @@ defmodule Sidecar.MetricsSupervisor do
{Sidecar.Measurements, :stats, [config]}
]
end

defp metrics_disabled?, do: System.get_env("SPAWN_DISABLE_METRICS", "false") !== "false"

defp console_metrics_disabled?,
do: System.get_env("SPAWN_CONSOLE_DISABLE_METRICS", "true") == "true"
end

0 comments on commit 92a5231

Please sign in to comment.