mirror of
https://github.com/valitydev/bouncer.git
synced 2024-11-06 02:15:18 +00:00
TD-187: Add Prometheus (#5)
This commit is contained in:
parent
af42521899
commit
9ae19918a9
@ -99,6 +99,9 @@
|
|||||||
{snowflake, [
|
{snowflake, [
|
||||||
{max_backward_clock_moving, 1000} % 1 second
|
{max_backward_clock_moving, 1000} % 1 second
|
||||||
% {machine_id, hostname_hash}
|
% {machine_id, hostname_hash}
|
||||||
]}
|
]},
|
||||||
|
|
||||||
|
{prometheus, [
|
||||||
|
{collectors, [default]}
|
||||||
|
]}
|
||||||
].
|
].
|
||||||
|
10
rebar.config
10
rebar.config
@ -93,6 +93,14 @@
|
|||||||
|
|
||||||
{profiles, [
|
{profiles, [
|
||||||
{prod, [
|
{prod, [
|
||||||
|
{deps, [
|
||||||
|
%% NOTE
|
||||||
|
%% Because of a dependency conflict, prometheus libs are only included in production build for now
|
||||||
|
%% https://github.com/project-fifo/rebar3_lint/issues/42
|
||||||
|
%% https://github.com/valitydev/hellgate/pull/2/commits/884724c1799703cee4d1033850fe32c17f986d9e
|
||||||
|
{prometheus, "4.8.1"},
|
||||||
|
{prometheus_cowboy, "0.1.8"}
|
||||||
|
]},
|
||||||
%% Relx configuration
|
%% Relx configuration
|
||||||
{relx, [
|
{relx, [
|
||||||
{release, {bouncer, "0.1.0"}, [
|
{release, {bouncer, "0.1.0"}, [
|
||||||
@ -106,6 +114,8 @@
|
|||||||
% logger formatter
|
% logger formatter
|
||||||
{logger_logstash_formatter, load},
|
{logger_logstash_formatter, load},
|
||||||
how_are_you,
|
how_are_you,
|
||||||
|
prometheus,
|
||||||
|
prometheus_cowboy,
|
||||||
bouncer
|
bouncer
|
||||||
]},
|
]},
|
||||||
{sys_config, "./config/sys.config"},
|
{sys_config, "./config/sys.config"},
|
||||||
|
@ -32,6 +32,10 @@ init([]) ->
|
|||||||
EventHandlers = genlib_app:env(?MODULE, woody_event_handlers, [woody_event_handler_default]),
|
EventHandlers = genlib_app:env(?MODULE, woody_event_handlers, [woody_event_handler_default]),
|
||||||
Healthcheck = enable_health_logging(genlib_app:env(?MODULE, health_check, #{})),
|
Healthcheck = enable_health_logging(genlib_app:env(?MODULE, health_check, #{})),
|
||||||
{OpaClient, OpaClientSpec} = bouncer_opa_client:init(get_opa_opts()),
|
{OpaClient, OpaClientSpec} = bouncer_opa_client:init(get_opa_opts()),
|
||||||
|
AdditionalRoutes = [
|
||||||
|
erl_health_handle:get_route(Healthcheck),
|
||||||
|
get_prometheus_route()
|
||||||
|
],
|
||||||
WoodySpec = woody_server:child_spec(
|
WoodySpec = woody_server:child_spec(
|
||||||
?MODULE,
|
?MODULE,
|
||||||
#{
|
#{
|
||||||
@ -44,7 +48,7 @@ init([]) ->
|
|||||||
handlers =>
|
handlers =>
|
||||||
get_handler_specs(ServiceOpts, AuditPulse, OpaClient) ++
|
get_handler_specs(ServiceOpts, AuditPulse, OpaClient) ++
|
||||||
get_stub_handler_specs(ServiceOpts),
|
get_stub_handler_specs(ServiceOpts),
|
||||||
additional_routes => [erl_health_handle:get_route(Healthcheck)]
|
additional_routes => AdditionalRoutes
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
{ok, {
|
{ok, {
|
||||||
@ -126,3 +130,7 @@ enable_health_logging(Check) ->
|
|||||||
fun(_, Runner) -> #{runner => Runner, event_handler => EvHandler} end,
|
fun(_, Runner) -> #{runner => Runner, event_handler => EvHandler} end,
|
||||||
Check
|
Check
|
||||||
).
|
).
|
||||||
|
|
||||||
|
-spec get_prometheus_route() -> {iodata(), module(), _Opts :: any()}.
|
||||||
|
get_prometheus_route() ->
|
||||||
|
{"/metrics/[:registry]", prometheus_cowboy2_handler, []}.
|
||||||
|
Loading…
Reference in New Issue
Block a user