Skip to content

Commit

Permalink
Added basic Prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sleipnir committed Nov 30, 2022
1 parent 06bbf67 commit 324e106
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 59 deletions.
109 changes: 60 additions & 49 deletions lib/actors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ defmodule Actors do
SpawnResponse
}

alias Sidecar.Measurements

import Spawn.Utils.Common, only: [to_existing_atom_or_new: 1]

@activate_actors_min_demand 0
Expand Down Expand Up @@ -169,58 +171,67 @@ defmodule Actors do
} = request,
opts \\ []
) do
metadata_attributes =
Enum.map(metadata, fn {key, value} -> {to_existing_atom_or_new(key), value} end) ++
[{:async, async?}, {"from", get_caller(caller)}, {"target", actor.id.name}]

{_current, opts} =
Keyword.get_and_update(opts, :span_ctx, fn v ->
if is_nil(v), do: {v, OpenTelemetry.Ctx.new()}, else: {v, v}
end)

Tracer.with_span opts[:span_ctx], "client invoke", kind: :client do
Tracer.set_attributes(metadata_attributes)

retry with: exponential_backoff() |> randomize |> expiry(10_000),
atoms: [:error, :exit, :noproc, :erpc, :noconnection],
rescue_only: [ErlangError] do
Tracer.add_event("lookup", [{"target", actor.id.name}])

actor_fqdn =
unless pooled? do
{pooled?, system.name, actor.id.name, actor.id.name}
{time, result} =
:timer.tc(fn ->
metadata_attributes =
Enum.map(metadata, fn {key, value} -> {to_existing_atom_or_new(key), value} end) ++
[{:async, async?}, {"from", get_caller(caller)}, {"target", actor.id.name}]

{_current, opts} =
Keyword.get_and_update(opts, :span_ctx, fn v ->
if is_nil(v), do: {v, OpenTelemetry.Ctx.new()}, else: {v, v}
end)

Tracer.with_span opts[:span_ctx], "client invoke", kind: :client do
Tracer.set_attributes(metadata_attributes)

retry with: exponential_backoff() |> randomize |> expiry(10_000),
atoms: [:error, :exit, :noproc, :erpc, :noconnection],
rescue_only: [ErlangError] do
Tracer.add_event("lookup", [{"target", actor.id.name}])

actor_fqdn =
unless pooled? do
{pooled?, system.name, actor.id.name, actor.id.name}
else
case ActorRegistry.get_hosts_by_actor(system.name, actor.id.name) do
{:ok, actor_hosts} ->
host = Enum.random(actor_hosts)
{pooled?, system.name, host.actor.id.parent, actor.id.name}

_ ->
{pooled?, system.name, "#{actor.id.name}-1", actor.id.name}
end
end

do_lookup_action(system.name, actor_fqdn, system, fn actor_ref, actor_ref_id ->
%InvocationRequest{
actor: %Actor{} = actor
} = request

request_params = %InvocationRequest{
request
| actor: %Actor{actor | id: actor_ref_id}
}

if is_nil(request.scheduled_to) || request.scheduled_to == 0 do
maybe_invoke_async(async?, actor_ref, request_params, opts)
else
InvocationScheduler.schedule_invoke(request_params)

{:ok, :async}
end
end)
after
result -> result
else
case ActorRegistry.get_hosts_by_actor(system.name, actor.id.name) do
{:ok, actor_hosts} ->
host = Enum.random(actor_hosts)
{pooled?, system.name, host.actor.id.parent, actor.id.name}

_ ->
{pooled?, system.name, "#{actor.id.name}-1", actor.id.name}
end
error -> error
end
end
end)

do_lookup_action(system.name, actor_fqdn, system, fn actor_ref, actor_ref_id ->
%InvocationRequest{
actor: %Actor{} = actor
} = request

request_params = %InvocationRequest{request | actor: %Actor{actor | id: actor_ref_id}}

if is_nil(request.scheduled_to) || request.scheduled_to == 0 do
maybe_invoke_async(async?, actor_ref, request_params, opts)
else
InvocationScheduler.schedule_invoke(request_params)

{:ok, :async}
end
end)
after
result -> result
else
error -> error
end
end
Measurements.emit_invoke_duration(system.name, actor.id.name, time)
result
end

defp get_caller(nil), do: "external"
Expand Down
2 changes: 1 addition & 1 deletion lib/actors/node/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Actors.Node.Client do

unknown ->
raise ArgumentError,
"Unknown Deployment Mode. Valid :sidecar or :daemon found #{inspect(unknown)}"
"Unknown Deployment Mode. Valid :sidecar or :daemon, found #{inspect(unknown)}"
end
end

Expand Down
19 changes: 19 additions & 0 deletions lib/sidecar/measurements.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule Sidecar.Measurements do
@moduledoc false

def dispatch_system_info() do
:telemetry.execute(
[:vm, :system_info, :process_count],
%{last_value: :erlang.system_info(:process_count)},
%{}
)
end

def emit_invoke_duration(system, actor_name, duration) do
:telemetry.execute([:spawn, :invoke, :stop], %{system: system, actor: actor_name, duration: duration})
end

def emit_actor_inflights(system, actor_name, value) do
:telemetry.execute([:spawn, :actor, :inflights], %{value: value}, %{system: system, actor: actor_name})
end
end
63 changes: 63 additions & 0 deletions lib/sidecar/metrics_supervisor.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
defmodule Sidecar.MetricsSupervisor do
@moduledoc false
use Supervisor
import Telemetry.Metrics

def start_link(arg) do
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
end

def init(_arg) do
children = [
{:telemetry_poller, measurements: periodic_measurements()},
{TelemetryMetricsPrometheus.Core, name: :spawm_metrics, metrics: metrics()},
{Telemetry.Metrics.ConsoleReporter, metrics: metrics()}
]

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

defp metrics do
[
# VM Metrics
last_value("vm.system_info.system_version"),
last_value("vm.system_info.otp_release"),
last_value("vm.system_info.process_count"),
# last_value("vm.system_info.schedulers"),
# last_value("vm.system_info.schedulers_online"),
# last_value("vm.system_info.dirty_cpu_schedulers"),
# last_value("vm.system_info.dirty_cpu_schedulers_online"),
# last_value("vm.system_info.multi_scheduling"),
# last_value("vm.system_info.threads"),
# last_value("vm.system_info.thread_pool_size"),
# last_value("vm.system_info.smp_support"),
# last_value("vm.system_info.dist_buf_busy_limit", unit: :byte),

last_value("vm.memory.total", unit: :byte),
last_value("vm.total_run_queue_lengths.total"),
last_value("vm.total_run_queue_lengths.cpu"),
last_value("vm.total_run_queue_lengths.io"),

# Actor Metrics
last_value("spawn.actor.memory", unit: :byte),
last_value("spawn.actor.message_queue_len"),
counter("spawn.invoke.stop.duration"),
summary("spawn.invoke.stop.duration", unit: {:native, :millisecond})

# Database Time Metrics
# summary("my_app.repo.query.total_time", unit: {:native, :millisecond}),
# summary("my_app.repo.query.decode_time", unit: {:native, :millisecond}),
# summary("my_app.repo.query.query_time", unit: {:native, :millisecond}),
# summary("my_app.repo.query.idle_time", unit: {:native, :millisecond}),
# summary("my_app.repo.query.queue_time", unit: {:native, :millisecond}),
]
end

defp periodic_measurements do
[
{:process_info,
event: [:spawn, :actor], name: Actors.Actor.Entity, keys: [:message_queue_len, :memory]},
{Sidecar.Measurements, :dispatch_system_info, []}
]
end
end
1 change: 1 addition & 0 deletions lib/sidecar/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Sidecar.Supervisor do
children =
[
statestores(),
{Sidecar.MetricsSupervisor, []},
Spawn.Supervisor.child_spec(config),
Actors.Supervisors.ProtocolSupervisor.child_spec(config),
Actors.Supervisors.EntitySupervisor.child_spec(config),
Expand Down
20 changes: 14 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ defmodule Spawn.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# Core deps
{:cowlib, "~> 2.9"},
{:decimal, "~> 2.0"},
{:protobuf, "~> 0.11"},
Expand All @@ -77,22 +78,29 @@ defmodule Spawn.MixProject do
{:vapor, "~> 0.10"},
{:libcluster, "~> 3.3"},
{:horde, "~> 0.8"},
{:highlander, "~> 0.2.1"},
{:phoenix_pubsub, "~> 2.1"},
{:phoenix_pubsub_nats, "~> 0.1.0"},
{:jason, "~> 1.3"},
# Metrics & Tracing deps
{:telemetry_poller, "~> 1.0"},
{:telemetry_metrics, "~> 0.6.1"},
{:telemetry_metrics_prometheus_core, "~> 1.1"},
{:opentelemetry_api, "~> 1.0"},
{:opentelemetry, "~> 1.0"},
{:opentelemetry_exporter, "~> 1.0"},
{:highlander, "~> 0.2.1"},
{:faker, "~> 0.17", only: :test},
{:mimic, "~> 1.7", only: :test},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:pluggable, "~> 1.0.1", only: :dev, runtime: false},
# Statestores deps
{:spawn_statestores_mssql, path: "./spawn_statestores/statestores_mssql", optional: false},
{:spawn_statestores_mysql, path: "./spawn_statestores/statestores_mysql", optional: false},
{:spawn_statestores_postgres, path: "./spawn_statestores/statestores_postgres", optional: false},
{:spawn_statestores_sqlite, path: "./spawn_statestores/statestores_sqlite", optional: false},
{:spawn_statestores_cockroachdb, path: "./spawn_statestores/statestores_cockroachdb", optional: false}
{:spawn_statestores_cockroachdb, path: "./spawn_statestores/statestores_cockroachdb", optional: false},
# Non runtime deps
{:faker, "~> 0.17", only: :test},
{:mimic, "~> 1.7", only: :test},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:pluggable, "~> 1.0.1", only: :dev, runtime: false}

]
end

Expand Down
6 changes: 4 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ex_doc": {:hex, :ex_doc, "0.29.1", "b1c652fa5f92ee9cf15c75271168027f92039b3877094290a75abcaac82a9f77", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "b7745fa6374a36daf484e2a2012274950e084815b936b1319aeebcf7809574f6"},
"exqlite": {:hex, :exqlite, "0.11.8", "b6bf596caa92d4811c303ddd8544dc9493a5351a18d2d16e1f85f977705cb39f", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "8591959284f1012c0d8cb26a09d5d9ba0bc0559cbeaf26fb8fbef14213d73bc0"},
"faker": {:hex, :faker, "0.17.0", "671019d0652f63aefd8723b72167ecdb284baf7d47ad3a82a15e9b8a6df5d1fa", [:mix], [], "hexpm", "a7d4ad84a93fd25c5f5303510753789fc2433ff241bf3b4144d3f6f291658a6a"},
"finch": {:hex, :finch, "0.13.0", "c881e5460ec563bf02d4f4584079e62201db676ed4c0ef3e59189331c4eddf7b", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "49957dcde10dcdc042a123a507a9c5ec5a803f53646d451db2f7dea696fba6cc"},
"finch": {:hex, :finch, "0.14.0", "619bfdee18fc135190bf590356c4bf5d5f71f916adb12aec94caa3fa9267a4bc", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5459acaf18c4fdb47a8c22fb3baff5d8173106217c8e56c5ba0b93e66501a8dd"},
"flow": {:hex, :flow, "1.2.0", "515e03aa3d056cecc3e3f1e80f6ca4bbf5f45b13c88dee5db880b2f3f24f1caa", [:mix], [{:gen_stage, "~> 1.0", [hex: :gen_stage, repo: "hexpm", optional: false]}], "hexpm", "1b45bfc8a9202c5ec80b077c21df133561e56c56189ba4082dddccb6b5762525"},
"gen_stage": {:hex, :gen_stage, "1.1.2", "b1656cd4ba431ed02c5656fe10cb5423820847113a07218da68eae5d6a260c23", [:mix], [], "hexpm", "9e39af23140f704e2b07a3e29d8f05fd21c2aaf4088ff43cb82be4b9e3148d02"},
"gettext": {:hex, :gettext, "0.20.0", "75ad71de05f2ef56991dbae224d35c68b098dd0e26918def5bb45591d5c8d429", [:mix], [], "hexpm", "1c03b177435e93a47441d7f681a7040bd2a816ece9e2666d1c9001035121eb3d"},
Expand Down Expand Up @@ -74,7 +74,7 @@
"mint": {:hex, :mint, "1.4.2", "50330223429a6e1260b2ca5415f69b0ab086141bc76dc2fbf34d7c389a6675b2", [:mix], [{:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "ce75a5bbcc59b4d7d8d70f8b2fc284b1751ffb35c7b6a6302b5192f8ab4ddd80"},
"msgpax": {:hex, :msgpax, "2.3.0", "14f52ad249a3f77b5e2d59f6143e6c18a6e74f34666989e22bac0a465f9835cc", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "65c36846a62ed5615baf7d7d47babb6541313a6c0b6d2ff19354bd518f52df7e"},
"myxql": {:hex, :myxql, "0.6.3", "3d77683a09f1227abb8b73d66b275262235c5cae68182f0cfa5897d72a03700e", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:geo, "~> 3.4", [hex: :geo, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "af9eb517ddaced5c5c28e8749015493757fd4413f2cfccea449c466d405d9f51"},
"nimble_options": {:hex, :nimble_options, "0.4.0", "c89babbab52221a24b8d1ff9e7d838be70f0d871be823165c94dd3418eea728f", [:mix], [], "hexpm", "e6701c1af326a11eea9634a3b1c62b475339ace9456c1a23ec3bc9a847bca02d"},
"nimble_options": {:hex, :nimble_options, "0.5.1", "5c166f7669e40333191bea38e3bd3811cc13f459f1e4be49e89128a21b5d8c4d", [:mix], [], "hexpm", "d176cf7baa4fef0ceb301ca3eb8b55bd7de3e45f489c4f8b4f2849f1f114ef3e"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"nimble_pool": {:hex, :nimble_pool, "0.2.6", "91f2f4c357da4c4a0a548286c84a3a28004f68f05609b4534526871a22053cde", [:mix], [], "hexpm", "1c715055095d3f2705c4e236c18b618420a35490da94149ff8b580a2144f653f"},
"nimble_strftime": {:hex, :nimble_strftime, "0.1.1", "b988184d1bd945bc139b2c27dd00a6c0774ec94f6b0b580083abd62d5d07818b", [:mix], [], "hexpm", "89e599c9b8b4d1203b7bb5c79eb51ef7c6a28fbc6228230b312f8b796310d755"},
Expand Down Expand Up @@ -116,6 +116,8 @@
"supervisor3": {:hex, :supervisor3, "1.1.11", "d81cdec31d102fde407423e1d05b569572850deebed86b951d5233c387cba80b", [:rebar3], [], "hexpm", "e6c2dedbcabcba24995a218aca12db5e208b80d3252692b22ef0f1a266104b50"},
"tds": {:hex, :tds, "2.3.2", "0499fd3049f024e2918a0a5c4f2072992fb7204f8e0b53cd325a8d930460765b", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "d6a17f0b17a4381fc18eee133ba3d31ba07e80337c3340e480ea257319d544f0"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
"telemetry_metrics_prometheus_core": {:hex, :telemetry_metrics_prometheus_core, "1.1.0", "4e15f6d7dbedb3a4e3aed2262b7e1407f166fcb9c30ca3f96635dfbbef99965c", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "0dd10e7fe8070095df063798f82709b0a1224c31b8baf6278b423898d591a069"},
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
"tesla": {:hex, :tesla, "1.4.4", "bb89aa0c9745190930366f6a2ac612cdf2d0e4d7fff449861baa7875afd797b2", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "d5503a49f9dec1b287567ea8712d085947e247cb11b06bc54adb05bfde466457"},
"thousand_island": {:hex, :thousand_island, "0.5.11", "5771bd889b16e20bdad2f0ab9831017511c229485f6461193b78e72bf3df51d9", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7e866dac9fdcd9225020021f7df1d8cef1896c0550684e9c0cc28ebb2cc3085b"},
Expand Down
2 changes: 2 additions & 0 deletions spawn_proxy/proxy/lib/proxy/router/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ defmodule Proxy.Router do

forward("/health", to: Proxy.Routes.Health)

forward("/metrics", to: Proxy.Routes.Metrics)

match _ do
send_resp(conn, 404, "Not found!")
end
Expand Down
4 changes: 3 additions & 1 deletion spawn_proxy/proxy/lib/proxy/routes/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule Proxy.Routes.Base do

plug(Plug.Parsers,
parsers: [:json, Proxy.Parsers.Protobuf],
pass: ["text/*"],
json_decoder: Jason
)

Expand All @@ -23,7 +24,8 @@ defmodule Proxy.Routes.Base do
end

def send!(conn, code, data, content_type)
when is_integer(code) and content_type == "application/octet-stream" do
when (is_integer(code) and content_type == "application/octet-stream") or
(is_integer(code) and content_type == "text/plain") do
conn
|> Plug.Conn.put_resp_content_type(content_type)
|> Plug.Conn.put_resp_header("Connection", "Keep-Alive")
Expand Down
12 changes: 12 additions & 0 deletions spawn_proxy/proxy/lib/proxy/routes/metrics.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
defmodule Proxy.Routes.Metrics do
use Proxy.Routes.Base

alias TelemetryMetricsPrometheus.Core, as: Prometheus

@content_type "text/plain"

get "/" do
scrape = Prometheus.scrape(:spawm_metrics)
send!(conn, 200, scrape, @content_type)
end
end
Loading

0 comments on commit 324e106

Please sign in to comment.