-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: move Prometheus integration to extension * chore: update devenv to include Grafana provisioning config for Prometheus * chore: update config for PromEx * feat: add Telemetry events * feat: add promex plugin * feat: add Grafana dashboard for deliveries
- Loading branch information
Showing
27 changed files
with
982 additions
and
49 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
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
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
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
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
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
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
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
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
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
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,23 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where third-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
tololo_extension_telegram_bot-*.tar | ||
|
||
# Temporary files, for example, from tests. | ||
/tmp/ |
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,44 @@ | ||
defmodule Tololo.Extensions.Prometheus do | ||
@moduledoc false | ||
use Supervisor | ||
@behaviour TololoCore.Extension | ||
|
||
@impl true | ||
def child_spec(init_arg) do | ||
%{ | ||
id: __MODULE__, | ||
start: {__MODULE__, :start_link, [init_arg]}, | ||
type: :supervisor, | ||
restart: :permanent | ||
} | ||
end | ||
|
||
def start_link(_init_arg) do | ||
Supervisor.start_link(__MODULE__, nil, name: __MODULE__) | ||
end | ||
|
||
@impl true | ||
def init(_) do | ||
children = [ | ||
Tololo.Extensions.Prometheus.PromEx | ||
] | ||
|
||
Supervisor.init(children, strategy: :one_for_all) | ||
end | ||
|
||
@impl true | ||
def routes() do | ||
quote do | ||
end | ||
end | ||
|
||
@impl true | ||
def endpoint() do | ||
quote do | ||
plug PromEx.Plug, prom_ex_module: Tololo.Extensions.Prometheus.PromEx | ||
end | ||
end | ||
|
||
@impl true | ||
def ash_domains(), do: [] | ||
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
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,67 @@ | ||
defmodule Tololo.Extensions.Prometheus.PromExPlugin do | ||
use PromEx.Plugin | ||
|
||
@impl true | ||
def event_metrics(_opts) do | ||
Event.build( | ||
:tololo_deliveries, | ||
[ | ||
counter( | ||
[:ash, :deliveries, :create, :count], | ||
event_name: [:ash, :deliveries, :create, :stop], | ||
description: "Total number of delivery creations", | ||
measurement: :count, | ||
tags: [:action], | ||
tag_values: fn metadata -> | ||
%{ | ||
action: metadata.action | ||
} | ||
end | ||
), | ||
counter( | ||
[:ash, :deliveries, :update, :state, :count], | ||
event_name: [:ash, :deliveries, :update, :stop], | ||
description: "Total number of state changes", | ||
measurement: :count, | ||
tags: [:action], | ||
tag_values: fn metadata -> | ||
%{ | ||
action: metadata.action | ||
} | ||
end | ||
), | ||
counter( | ||
[:ash, :deliveries, :update, :state, :individual, :count], | ||
event_name: [:ash, :deliveries, :update, :state], | ||
description: "Total number of state changes for individual state", | ||
measurement: :count, | ||
tags: [:action, :state], | ||
tag_values: fn metadata -> | ||
%{ | ||
action: metadata.action, | ||
state: metadata.new_state | ||
} | ||
end | ||
), | ||
counter( | ||
[:ash, :users, :approve, :count], | ||
event_name: [:ash, :users, :approve], | ||
description: "Total number of approved users", | ||
measurement: :count | ||
), | ||
counter( | ||
[:ash, :users, :delivery, :assigned, :count], | ||
event_name: [:ash, :users, :delivery, :assigned], | ||
description: "Total number of assigned deliveries to users", | ||
measurement: :count | ||
), | ||
counter( | ||
[:ash, :users, :delivery, :done, :count], | ||
event_name: [:ash, :users, :delivery, :done], | ||
description: "Total number of deliveries marked as done by users", | ||
measurement: :count | ||
) | ||
] | ||
) | ||
end | ||
end |
Oops, something went wrong.