-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2850372
commit 52587d5
Showing
6 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
defmodule Dotcom.Telemetry do | ||
@moduledoc """ | ||
""" | ||
|
||
use Supervisor | ||
|
||
alias Telemetry.Metrics | ||
|
||
def start_link(arg) do | ||
Supervisor.start_link(__MODULE__, arg, name: __MODULE__) | ||
end | ||
|
||
def init(_arg) do | ||
telemetry_metrics_splunk_config = Application.get_env(:dotcom, :telemetry_metrics_splunk) | ||
|
||
children = [ | ||
{ | ||
TelemetryMetricsSplunk, | ||
[ | ||
metrics: metrics(), | ||
token: telemetry_metrics_splunk_config[:token], | ||
url: telemetry_metrics_splunk_config[:url] | ||
] | ||
} | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_one) | ||
end | ||
|
||
defp metrics do | ||
[ | ||
Metrics.last_value("vm.memory.total", unit: :byte), | ||
Metrics.last_value("vm.total_run_queue_lengths.total"), | ||
Metrics.last_value("vm.total_run_queue_lengths.cpu"), | ||
Metrics.last_value("vm.system_counts.process_count") | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
defmodule DotcomWeb.Stats do | ||
@moduledoc """ | ||
This Agent attaches to telemetry events emitted by Phoenix and aggregates them. | ||
""" | ||
|
||
use Agent | ||
|
||
@doc """ | ||
Starts the Agent and attaches to `[:phoenix, ...]` telemetry events. | ||
""" | ||
def start_link(initial_value \\ %{}) do | ||
Agent.start_link(fn -> initial_value end, name: __MODULE__) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
defmodule DotcomWeb.Telemetry do | ||
@moduledoc """ | ||
This module is responsible for starting the Telemetry poller and defining the metrics to be collected for Phoenix and the Erlang VM. | ||
""" | ||
|
||
use Supervisor | ||
|
||
alias Telemetry.Metrics | ||
|
||
def start_link(arg) do | ||
Supervisor.start_link(__MODULE__, arg, name: __MODULE__) | ||
end | ||
|
||
@impl true | ||
def init(_arg) do | ||
telemetry_metrics_splunk_config = Application.get_env(:dotcom, :telemetry_metrics_splunk) | ||
|
||
children = [ | ||
{ | ||
TelemetryMetricsSplunk, | ||
[ | ||
metrics: metrics(), | ||
token: telemetry_metrics_splunk_config[:token], | ||
url: telemetry_metrics_splunk_config[:url] | ||
] | ||
}, | ||
{DotcomWeb.Stats, %{}} | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_one) | ||
end | ||
|
||
def measurements do | ||
[] | ||
end | ||
|
||
def metrics do | ||
[] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters