diff --git a/.github/workflows/erlang-checks.yml b/.github/workflows/erlang-checks.yml index 175d0ef..28e0363 100644 --- a/.github/workflows/erlang-checks.yml +++ b/.github/workflows/erlang-checks.yml @@ -36,5 +36,5 @@ jobs: rebar-version: ${{ needs.setup.outputs.rebar-version }} use-thrift: true thrift-version: ${{ needs.setup.outputs.thrift-version }} - cache-version: v2 + cache-version: v3 upload-coverage: false diff --git a/apps/capi/src/capi.app.src b/apps/capi/src/capi.app.src index 8a24850..69ff142 100644 --- a/apps/capi/src/capi.app.src +++ b/apps/capi/src/capi.app.src @@ -10,6 +10,8 @@ snowflake, genlib, feat, + prometheus, + prometheus_cowboy, woody, capi_woody_client, damsel, diff --git a/apps/capi/src/capi.erl b/apps/capi/src/capi.erl index 7a0beda..8c914d9 100644 --- a/apps/capi/src/capi.erl +++ b/apps/capi/src/capi.erl @@ -13,8 +13,14 @@ -spec start(normal, any()) -> {ok, pid()} | {error, any()}. start(_StartType, _StartArgs) -> + ok = setup_metrics(), capi_sup:start_link(). -spec stop(any()) -> ok. stop(_State) -> ok. +%% + +setup_metrics() -> + ok = woody_ranch_prometheus_collector:setup(), + ok = woody_hackney_prometheus_collector:setup(). diff --git a/apps/capi/test/capi_bouncer_data.hrl b/apps/capi/test/capi_bouncer_data.hrl index afb03e0..50ebbc5 100644 --- a/apps/capi/test/capi_bouncer_data.hrl +++ b/apps/capi/test/capi_bouncer_data.hrl @@ -157,13 +157,6 @@ party = ?CTX_ENTITY(PartyID) }). --define(CTX_PAYOUT(ID, PartyID, ContractID, ShopID), #ctx_v1_Payout{ - id = ID, - party = ?CTX_ENTITY(PartyID), - contract = ?CTX_ENTITY(ContractID), - shop = ?CTX_ENTITY(ShopID) -}). - -define(assertContextMatches(Expect), fun(Context) -> try ?assertMatch(Expect, Context), diff --git a/apps/capi/test/capi_dummy_data.hrl b/apps/capi/test/capi_dummy_data.hrl index c170ccc..1ee8207 100644 --- a/apps/capi/test/capi_dummy_data.hrl +++ b/apps/capi/test/capi_dummy_data.hrl @@ -431,12 +431,7 @@ status = {active, #domain_ContractActive{}}, terms = #domain_TermSetHierarchyRef{id = ?INTEGER}, adjustments = [?CONTRACT_ADJUSTMENT], - payout_tools = [ - ?PAYOUT_TOOL(?BANKID_RU, ?RUSSIAN_BANK_ACCOUNT), - ?PAYOUT_TOOL(?BANKID_US, ?INTERNATIONAL_BANK_ACCOUNT), - ?PAYOUT_TOOL(?WALLET_TOOL, ?WALLET_INFO), - ?PAYOUT_TOOL(?PI_ACCOUNT_TOOL, ?PAYMENT_INSTITUTION_ACCOUNT) - ], + payout_tools = [], legal_agreement = ?CONTRACT_LEGAL_AGREEMENT, report_preferences = ?CONTRACT_REPORT_PREFS }). @@ -904,10 +899,7 @@ minute = {every, #'base_ScheduleEvery'{}}, second = {every, #'base_ScheduleEvery'{}} }, - delay = #'base_TimeSpan'{}, - policy = #domain_PayoutCompilationPolicy{ - assets_freeze_for = #'base_TimeSpan'{} - } + delay = #'base_TimeSpan'{} } }}, {globals, #domain_GlobalsRef{}} => @@ -1075,12 +1067,9 @@ }). -define(TERM_SET, #domain_TermSet{ - payouts = ?PAYOUTS_SERVICE_TERMS, payments = ?PAYMENTS_SERVICE_TERMS }). --define(PAYOUTS_SERVICE_TERMS, #domain_PayoutsServiceTerms{}). - -define(PAYMENTS_SERVICE_TERMS, #domain_PaymentsServiceTerms{ payment_methods = {value, @@ -1309,15 +1298,6 @@ <<"metadata">> => #{<<"text">> => [<<"SOMESHIT">>, 42]} }). --define(PAYOUT_PARAMS, #{ - <<"id">> => ?STRING, - <<"shopID">> => ?STRING, - <<"partyID">> => ?STRING, - <<"payoutToolID">> => ?WALLET_TOOL, - <<"amount">> => 2, - <<"currency">> => <<"RUB">> -}). - -define(PAYMENT_PARAMS(EID, Token), #{ <<"externalID">> => EID, <<"flow">> => #{<<"type">> => <<"PaymentFlowInstant">>}, diff --git a/config/sys.config b/config/sys.config index 95c9573..7d9caf5 100644 --- a/config/sys.config +++ b/config/sys.config @@ -212,5 +212,9 @@ {prometheus, [ {collectors, [default]} + ]}, + + {hackney, [ + {mod_metrics, woody_hackney_prometheus} ]} ]. diff --git a/rebar.config b/rebar.config index f4c4927..55eda3c 100644 --- a/rebar.config +++ b/rebar.config @@ -26,6 +26,8 @@ %% Common project dependencies. {deps, [ + {prometheus, "4.8.1"}, + {prometheus_cowboy, "0.1.8"}, {cowboy, "2.9.0"}, %% NOTE %% Pinning to version "1.11.2" from hex here causes constant upgrading and recompilation of the entire project @@ -93,8 +95,6 @@ %% 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"}, {recon, "2.3.6"}, {logger_logstash_formatter, {git, "https://github.com/valitydev/logger_logstash_formatter.git", {ref, "08a66a6"}}}, @@ -144,3 +144,11 @@ "ct.coverdata" ]} ]}. + +%% NOTE +%% It is needed to use rebar3 lint plugin +{overrides, [ + {del, accept, [{plugins, [{rebar3_archive_plugin, "0.0.2"}]}]}, + {del, prometheus_cowboy, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]}, + {del, prometheus_httpd, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]} +]}. diff --git a/rebar.lock b/rebar.lock index a5d91ab..6ce1507 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,5 +1,6 @@ {"1.2.0", -[{<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},2}, +[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.5">>},2}, + {<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},2}, {<<"bender_client">>, {git,"https://github.com/valitydev/bender-client-erlang.git", {ref,"d8837617c8dc36216ce8c4ffc9a56a34e423ca5e"}}, @@ -40,7 +41,7 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"e5d3c83a240ba716348c6fbd816ea8e4d864472f"}}, + {ref,"8e034bc74b1f4ed0e00dd63d0c3ca9c922be1c47"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt_client.git", @@ -87,7 +88,7 @@ 0}, {<<"magista_proto">>, {git,"https://github.com/valitydev/magista-proto.git", - {ref,"5352f74dd5791bf72e2c4b8b652c794b45aa6a30"}}, + {ref,"ec1bdb95b29d1562372b2178b277278054acb264"}}, 0}, {<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2}, {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},2}, @@ -120,8 +121,10 @@ {git,"https://github.com/valitydev/payproc-errors-erlang.git", {ref,"a19e716966b7206e96fbd767661d6fd3bab3119d"}}, 0}, - {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},1}, - {<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},2}, + {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},0}, + {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0}, + {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.11">>},1}, + {<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1}, {<<"scoper">>, {git,"https://github.com/valitydev/scoper.git", @@ -166,6 +169,7 @@ 0}]}. [ {pkg_hash,[ + {<<"accept">>, <<"B33B127ABCA7CC948BBE6CAA4C263369ABF1347CFA9D8E699C6D214660F10CD1">>}, {<<"acceptor_pool">>, <<"43C20D2ACAE35F0C2BCD64F9D2BDE267E459F0F3FD23DAB26485BF518C281B21">>}, {<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>}, {<<"certifi">>, <<"DBAB8E5E155A0763EEA978C913CA280A6B544BFA115633FA20249C3D396D9493">>}, @@ -188,12 +192,15 @@ {<<"opentelemetry_semantic_conventions">>, <<"B67FE459C2938FCAB341CB0951C44860C62347C005ACE1B50F8402576F241435">>}, {<<"parse_trans">>, <<"6E6AA8167CB44CC8F39441D05193BE6E6F4E7C2946CB2759F015F8C56B76E5FF">>}, {<<"prometheus">>, <<"FA76B152555273739C14B06F09F485CF6D5D301FE4E9D31B7FF803D26025D7A0">>}, + {<<"prometheus_cowboy">>, <<"CFCE0BC7B668C5096639084FCD873826E6220EA714BF60A716F5BD080EF2A99C">>}, + {<<"prometheus_httpd">>, <<"F616ED9B85B536B195D94104063025A91F904A4CFC20255363F49A197D96C896">>}, {<<"quantile_estimator">>, <<"EF50A361F11B5F26B5F16D0696E46A9E4661756492C981F7B2229EF42FF1CD15">>}, {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, {<<"ssl_verify_fun">>, <<"354C321CF377240C7B8716899E182CE4890C5938111A1296ADD3EC74CF1715DF">>}, {<<"tls_certificate_check">>, <<"C76C4C5D79EE79A2B11C84F910C825D6F024A78427C854F515748E9BD025E987">>}, {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, {pkg_hash_ext,[ + {<<"accept">>, <<"11B18C220BCC2EAB63B5470C038EF10EB6783BCB1FCDB11AA4137DEFA5AC1BB8">>}, {<<"acceptor_pool">>, <<"0CBCD83FDC8B9AD2EEE2067EF8B91A14858A5883CB7CD800E6FCD5803E158788">>}, {<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>}, {<<"certifi">>, <<"524C97B4991B3849DD5C17A631223896272C6B0AF446778BA4675A1DFF53BB7E">>}, @@ -216,6 +223,8 @@ {<<"opentelemetry_semantic_conventions">>, <<"D61FA1F5639EE8668D74B527E6806E0503EFC55A42DB7B5F39939D84C07D6895">>}, {<<"parse_trans">>, <<"620A406CE75DADA827B82E453C19CF06776BE266F5A67CFF34E1EF2CBB60E49A">>}, {<<"prometheus">>, <<"6EDFBE928D271C7F657A6F2C46258738086584BD6CAE4A000B8B9A6009BA23A5">>}, + {<<"prometheus_cowboy">>, <<"BA286BECA9302618418892D37BCD5DC669A6CC001F4EB6D6AF85FF81F3F4F34C">>}, + {<<"prometheus_httpd">>, <<"0BBE831452CFDF9588538EB2F570B26F30C348ADAE5E95A7D87F35A5910BCF92">>}, {<<"quantile_estimator">>, <<"282A8A323CA2A845C9E6F787D166348F776C1D4A41EDE63046D72D422E3DA946">>}, {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, {<<"ssl_verify_fun">>, <<"FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8">>},