MSPF-579 Add prometheus.erl library usage (#36)

This commit is contained in:
Andrey Fadeev 2020-10-22 11:04:41 +03:00 committed by GitHub
parent 112656937f
commit b0eea3098f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 4 deletions

View File

@ -11,7 +11,9 @@
how_are_you, % must be after ranch and before any woody usage
scoper, % should be before any scoper event handler usage
machinery,
erl_health
erl_health,
prometheus,
prometheus_cowboy
]},
{mod, {bender, []}},
{env, []}

View File

@ -121,7 +121,7 @@ get_routes(EventHandlers) ->
}}
],
Check = enable_health_logging(genlib_app:env(?MODULE, health_check, #{})),
[erl_health_handle:get_route(Check) | machinery_mg_backend:get_routes(Handlers, RouteOpts)].
[erl_health_handle:get_route(Check), get_prometheus_route() | machinery_mg_backend:get_routes(Handlers, RouteOpts)].
-spec enable_health_logging(erl_health:check()) -> erl_health:check().
enable_health_logging(Check) ->
@ -130,3 +130,7 @@ enable_health_logging(Check) ->
fun(_, Runner) -> #{runner => Runner, event_handler => EvHandler} end,
Check
).
-spec get_prometheus_route() -> {iodata(), module(), _Opts :: any()}.
get_prometheus_route() ->
{"/metrics/[:registry]", prometheus_cowboy2_handler, []}.

View File

@ -104,5 +104,9 @@
{snowflake, [
{max_backward_clock_moving, 1000} % 1 second
% {machine_id, hostname_hash} % you MUST set this option in production
]},
{prometheus, [
{collectors, [default]}
]}
].

View File

@ -61,7 +61,9 @@
{woody,
{git, "https://github.com/rbkmoney/woody_erlang.git",
{branch, "master"}}
}
},
{prometheus, "4.6.0"},
{prometheus_cowboy, "0.1.8"}
]}.

View File

@ -1,5 +1,6 @@
{"1.2.0",
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.5">>},2},
{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
{<<"bender_proto">>,
{git,"git@github.com:rbkmoney/bender-proto.git",
{ref,"0d5813b8a25c8d03e4e59e42aa5f4e9b785a3849"}},
@ -51,6 +52,9 @@
{ref,"ec15d5e854ea60c58467373077d90c2faf6273d8"}},
1},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},2},
{<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.6.0">>},0},
{<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0},
{<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.11">>},1},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},2},
{<<"scoper">>,
{git,"https://github.com/rbkmoney/scoper.git",
@ -72,6 +76,7 @@
0}]}.
[
{pkg_hash,[
{<<"accept">>, <<"B33B127ABCA7CC948BBE6CAA4C263369ABF1347CFA9D8E699C6D214660F10CD1">>},
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>},
{<<"cache">>, <<"3C11DBF4CD8FCD5787C95A5FB2A04038E3729CFCA0386016EEA8C953AB48A5AB">>},
{<<"certifi">>, <<"B7CFEAE9D2ED395695DD8201C57A2D019C0C43ECAF8B8BCB9320B40D6662F340">>},
@ -84,10 +89,14 @@
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"prometheus">>, <<"20510F381DB1CCAB818B4CF2FAC5FA6AB5CC91BC364A154399901C001465F46F">>},
{<<"prometheus_cowboy">>, <<"CFCE0BC7B668C5096639084FCD873826E6220EA714BF60A716F5BD080EF2A99C">>},
{<<"prometheus_httpd">>, <<"F616ED9B85B536B195D94104063025A91F904A4CFC20255363F49A197D96C896">>},
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>},
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>},
{<<"unicode_util_compat">>, <<"8516502659002CEC19E244EBD90D312183064BE95025A319A6C7E89F4BCCD65B">>}]},
{pkg_hash_ext,[
{<<"accept">>, <<"11B18C220BCC2EAB63B5470C038EF10EB6783BCB1FCDB11AA4137DEFA5AC1BB8">>},
{<<"bear">>, <<"534217DCE6A719D59E54FB0EB7A367900DBFC5F85757E8C1F94269DF383F6D9B">>},
{<<"cache">>, <<"3E7D6706DE5DF76C4D71C895B4BE62B01C3DE6EDB63197035E465C3BCE63F19B">>},
{<<"certifi">>, <<"3B3B5F36493004AC3455966991EAF6E768CE9884693D9968055AEEEB1E575040">>},
@ -100,6 +109,9 @@
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
{<<"parse_trans">>, <<"17EF63ABDE837AD30680EA7F857DD9E7CED9476CDD7B0394432AF4BFC241B960">>},
{<<"prometheus">>, <<"4905FD2992F8038ECCD7AA0CD22F40637ED618C0BED1F75C05AACEC15B7545DE">>},
{<<"prometheus_cowboy">>, <<"BA286BECA9302618418892D37BCD5DC669A6CC001F4EB6D6AF85FF81F3F4F34C">>},
{<<"prometheus_httpd">>, <<"0BBE831452CFDF9588538EB2F570B26F30C348ADAE5E95A7D87F35A5910BCF92">>},
{<<"ranch">>, <<"451D8527787DF716D99DC36162FCA05934915DB0B6141BBDAC2EA8D3C7AFC7D7">>},
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>},
{<<"unicode_util_compat">>, <<"D48D002E15F5CC105A696CF2F1BBB3FC72B4B770A184D8420C8DB20DA2674B38">>}]}