add metrics for number of crypto operations

This commit is contained in:
Marco Boss 2022-03-14 20:06:07 +01:00
parent 687f0cab82
commit 7529939a0f
No known key found for this signature in database
GPG Key ID: 89A3EC33C625C3DF
31 changed files with 113 additions and 45 deletions

View File

@ -140,6 +140,7 @@ add_auditor_denom_sig (void *cls,
TALER_B2S (awc->auditor_pub));
return GNUNET_DB_STATUS_HARD_ERROR;
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_auditor_denom_validity_verify (
auditor_url,
@ -213,7 +214,7 @@ TEH_handler_auditors (
return MHD_YES; /* failure */
ret = TEH_DB_run_transaction (connection,
"add auditor denom sig",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&res,
&add_auditor_denom_sig,
&awc);

View File

@ -81,7 +81,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
enum GNUNET_GenericReturnValue
TEH_DB_run_transaction (struct MHD_Connection *connection,
const char *name,
enum TEH_MetricType mt,
enum TEH_MetricTypeRequest mt,
MHD_RESULT *mhd_ret,
TEH_DB_TransactionCallback cb,
void *cb_cls)
@ -99,7 +99,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
NULL);
return GNUNET_SYSERR;
}
GNUNET_assert (mt < TEH_MT_COUNT);
GNUNET_assert (mt < TEH_MT_REQUEST_COUNT);
TEH_METRICS_num_requests[mt]++;
for (unsigned int retries = 0;
retries < MAX_TRANSACTION_COMMIT_RETRIES;

View File

@ -96,7 +96,7 @@ typedef enum GNUNET_DB_QueryStatus
enum GNUNET_GenericReturnValue
TEH_DB_run_transaction (struct MHD_Connection *connection,
const char *name,
enum TEH_MetricType mt,
enum TEH_MetricTypeRequest mt,
MHD_RESULT *mhd_ret,
TEH_DB_TransactionCallback cb,
void *cb_cls);

View File

@ -382,6 +382,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
deposit.deposit_fee = dk->meta.fees.deposit;
/* check coin signature */
TEH_METRICS_num_verifications[TEH_MT_CIPHER]++;
if (GNUNET_YES !=
TALER_test_coin_valid (&deposit.coin,
&dk->denom_pub))
@ -405,6 +406,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
NULL);
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_deposit_verify (&deposit.amount_with_fee,
&deposit.deposit_fee,
@ -472,7 +474,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"execute deposit",
TEH_MT_DEPOSIT,
TEH_MT_REQUEST_DEPOSIT,
&mhd_ret,
&deposit_transaction,
&dc))

View File

@ -247,7 +247,7 @@ handle_track_transaction_request (
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"handle deposits GET",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&deposits_get_transaction,
&ctx))
@ -344,6 +344,7 @@ TEH_handler_deposits_get (struct TEH_RequestContext *rc,
return MHD_NO; /* internal error */
if (GNUNET_NO == res)
return MHD_YES; /* parse error */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION,
&tps,

View File

@ -2453,6 +2453,7 @@ TEH_keys_denomination_sign_withdraw (
switch (hd->denom_pub.cipher)
{
case TALER_DENOMINATION_RSA:
TEH_METRICS_num_signatures[TEH_MT_CIPHER]++;
return TALER_CRYPTO_helper_rsa_sign (
ksh->helpers->rsadh,
&hd->h_details.h_rsa,
@ -2460,6 +2461,7 @@ TEH_keys_denomination_sign_withdraw (
bp->details.rsa_blinded_planchet.blinded_msg_size,
bs);
case TALER_DENOMINATION_CS:
TEH_METRICS_num_signatures[TEH_MT_CIPHER]++;
return TALER_CRYPTO_helper_cs_sign_withdraw (
ksh->helpers->csdh,
&hd->h_details.h_cs,
@ -2492,6 +2494,7 @@ TEH_keys_denomination_sign_melt (
switch (hd->denom_pub.cipher)
{
case TALER_DENOMINATION_RSA:
TEH_METRICS_num_signatures[TEH_MT_CIPHER]++;
return TALER_CRYPTO_helper_rsa_sign (
ksh->helpers->rsadh,
&hd->h_details.h_rsa,
@ -2499,6 +2502,7 @@ TEH_keys_denomination_sign_melt (
bp->details.rsa_blinded_planchet.blinded_msg_size,
bs);
case TALER_DENOMINATION_CS:
TEH_METRICS_num_signatures[TEH_MT_CIPHER]++;
return TALER_CRYPTO_helper_cs_sign_melt (
ksh->helpers->csdh,
&hd->h_details.h_cs,
@ -2645,6 +2649,7 @@ TEH_keys_exchange_sign2_ (
{
enum TALER_ErrorCode ec;
TEH_METRICS_num_signatures[TEH_MT_EDDSA]++;
ec = TALER_CRYPTO_helper_esign_sign_ (ksh->helpers->esh,
purpose,
pub,

View File

@ -345,7 +345,7 @@ TEH_handler_kyc_check (
now = GNUNET_TIME_timestamp_get ();
ret = TEH_DB_run_transaction (rc->connection,
"kyc check",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&res,
&kyc_check,
kyp);

View File

@ -675,7 +675,7 @@ TEH_handler_kyc_proof (
ret = TEH_DB_run_transaction (kpc->rc->connection,
"check proof kyc",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&res,
&persist_kyc_ok,
kpc);

View File

@ -118,6 +118,7 @@ TEH_handler_kyc_wallet (
if (GNUNET_NO == ret)
return MHD_YES; /* failure */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify_ (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP,
&purpose,
@ -140,7 +141,7 @@ TEH_handler_kyc_wallet (
0);
ret = TEH_DB_run_transaction (rc->connection,
"check wallet kyc",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&res,
&wallet_kyc_check,
&krc);

View File

@ -203,7 +203,7 @@ TEH_handler_link (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"run link",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&link_transaction,
&ctx))

View File

@ -189,7 +189,7 @@ TEH_handler_management_auditors (
ret = TEH_DB_run_transaction (connection,
"add auditor",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&res,
&add_auditor,
&aac);

View File

@ -178,7 +178,7 @@ TEH_handler_management_auditors_AP_disable (
ret = TEH_DB_run_transaction (connection,
"del auditor",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&res,
&del_auditor,
&dac);

View File

@ -56,6 +56,7 @@ TEH_handler_management_denominations_HDP_revoke (
if (GNUNET_NO == res)
return MHD_YES; /* failure */
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_denomination_revoke_verify (
h_denom_pub,

View File

@ -278,7 +278,7 @@ TEH_handler_management_post_extensions (
res = TEH_DB_run_transaction (connection,
"set extensions",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&ret,
&set_extensions,
&sec);

View File

@ -221,6 +221,7 @@ TEH_handler_management_post_global_fees (
return MHD_YES; /* failure */
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_global_fee_verify (
afc.start_time,
@ -248,7 +249,7 @@ TEH_handler_management_post_global_fees (
res = TEH_DB_run_transaction (connection,
"add global fee",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&ret,
&add_fee,
&afc);

View File

@ -179,6 +179,7 @@ add_keys (void *cls,
}
/* check signature is valid */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_denom_validity_verify (
&d->h_denom_pub,
@ -277,6 +278,7 @@ add_keys (void *cls,
}
/* check signature is valid */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_signkey_validity_verify (
&s->exchange_pub,
@ -459,7 +461,7 @@ TEH_handler_management_post_keys (
res = TEH_DB_run_transaction (connection,
"add keys",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&ret,
&add_keys,
&akc);

View File

@ -56,6 +56,7 @@ TEH_handler_management_signkeys_EP_revoke (
if (GNUNET_NO == res)
return MHD_YES; /* failure */
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_signkey_revoke_verify (exchange_pub,
&TEH_master_public_key,

View File

@ -179,7 +179,7 @@ TEH_handler_management_post_wire_disable (
res = TEH_DB_run_transaction (connection,
"del wire",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&ret,
&del_wire,
&awc);

View File

@ -165,6 +165,7 @@ TEH_handler_management_post_wire (
if (GNUNET_NO == res)
return MHD_YES; /* failure */
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_wire_add_verify (awc.payto_uri,
awc.validity_start,
@ -178,6 +179,7 @@ TEH_handler_management_post_wire (
TALER_EC_EXCHANGE_MANAGEMENT_WIRE_ADD_SIGNATURE_INVALID,
NULL);
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_wire_signature_check (awc.payto_uri,
&TEH_master_public_key,
@ -214,7 +216,7 @@ TEH_handler_management_post_wire (
res = TEH_DB_run_transaction (connection,
"add wire",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&ret,
&add_wire,
&awc);

View File

@ -188,6 +188,7 @@ TEH_handler_management_post_wire_fees (
return MHD_YES; /* failure */
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_exchange_offline_wire_fee_verify (
afc.wire_method,
@ -212,7 +213,7 @@ TEH_handler_management_post_wire_fees (
res = TEH_DB_run_transaction (connection,
"add wire fee",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&ret,
&add_fee,
&afc);

View File

@ -265,7 +265,7 @@ database_melt (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run melt",
TEH_MT_MELT,
TEH_MT_REQUEST_MELT,
&mhd_ret,
&melt_transaction,
rmc))
@ -341,7 +341,7 @@ check_melt_valid (struct MHD_Connection *connection,
TALER_EC_EXCHANGE_MELT_FEES_EXCEED_CONTRIBUTION,
NULL);
}
TEH_METRICS_num_verifications[TEH_MT_CIPHER]++;
if (GNUNET_OK !=
TALER_test_coin_valid (&rmc->refresh_session.coin,
&dk->denom_pub))
@ -354,6 +354,7 @@ check_melt_valid (struct MHD_Connection *connection,
}
/* verify signature of coin for melt operation */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_melt_verify (&rmc->refresh_session.amount_with_fee,
&rmc->coin_refresh_fee,

View File

@ -29,10 +29,13 @@
#include <jansson.h>
unsigned long long TEH_METRICS_num_requests[TEH_MT_COUNT];
unsigned long long TEH_METRICS_num_requests[TEH_MT_REQUEST_COUNT];
unsigned long long TEH_METRICS_num_conflict[TEH_MT_COUNT];
unsigned long long TEH_METRICS_num_conflict[TEH_MT_REQUEST_COUNT];
unsigned long long TEH_METRICS_num_signatures[TEH_MT_CIPHER_COUNT];
unsigned long long TEH_METRICS_num_verifications[TEH_MT_CIPHER_COUNT];
MHD_RESULT
TEH_handler_metrics (struct TEH_RequestContext *rc,
@ -57,23 +60,41 @@ TEH_handler_metrics (struct TEH_RequestContext *rc,
"taler_exchange_received_requests{type=\"%s\"} %llu\n"
"taler_exchange_received_requests{type=\"%s\"} %llu\n"
"taler_exchange_received_requests{type=\"%s\"} %llu\n"
"taler_exchange_received_requests{type=\"%s\"} %llu\n",
"taler_exchange_received_requests{type=\"%s\"} %llu\n"
"# HELP taler_exchange_num_signatures "
" number of signatures created by cipher (rsa, cs) and eddsa\n"
"# TYPE taler_exchange_num_signatures counter\n"
"taler_exchange_num_signatures{type=\"%s\"} %llu\n"
"taler_exchange_num_signatures{type=\"%s\"} %llu\n"
"# HELP taler_exchange_num_signature_verifications "
" number of signatures verified by cipher (rsa, cs) and eddsa\n"
"# TYPE taler_exchange_num_signature_verifications counter\n"
"taler_exchange_num_signature_verifications{type=\"%s\"} %llu\n"
"taler_exchange_num_signature_verifications{type=\"%s\"} %llu\n",
"other",
TEH_METRICS_num_conflict[TEH_MT_OTHER],
TEH_METRICS_num_conflict[TEH_MT_REQUEST_OTHER],
"deposit",
TEH_METRICS_num_conflict[TEH_MT_DEPOSIT],
TEH_METRICS_num_conflict[TEH_MT_REQUEST_DEPOSIT],
"withdraw",
TEH_METRICS_num_conflict[TEH_MT_WITHDRAW],
TEH_METRICS_num_conflict[TEH_MT_REQUEST_WITHDRAW],
"melt",
TEH_METRICS_num_conflict[TEH_MT_MELT],
TEH_METRICS_num_conflict[TEH_MT_REQUEST_MELT],
"other",
TEH_METRICS_num_requests[TEH_MT_OTHER],
TEH_METRICS_num_requests[TEH_MT_REQUEST_OTHER],
"deposit",
TEH_METRICS_num_requests[TEH_MT_DEPOSIT],
TEH_METRICS_num_requests[TEH_MT_REQUEST_DEPOSIT],
"withdraw",
TEH_METRICS_num_requests[TEH_MT_WITHDRAW],
TEH_METRICS_num_requests[TEH_MT_REQUEST_WITHDRAW],
"melt",
TEH_METRICS_num_requests[TEH_MT_MELT]);
TEH_METRICS_num_requests[TEH_MT_REQUEST_MELT],
"cipher",
TEH_METRICS_num_signatures[TEH_MT_CIPHER],
"eddsa",
TEH_METRICS_num_signatures[TEH_MT_EDDSA],
"cipher",
TEH_METRICS_num_verifications[TEH_MT_CIPHER],
"eddsa",
TEH_METRICS_num_verifications[TEH_MT_EDDSA]);
resp = MHD_create_response_from_buffer (strlen (reply),
reply,
MHD_RESPMEM_MUST_FREE);

View File

@ -29,27 +29,45 @@
/**
* Request types for which we collect metrics.
*/
enum TEH_MetricType
enum TEH_MetricTypeRequest
{
TEH_MT_OTHER = 0,
TEH_MT_DEPOSIT = 1,
TEH_MT_WITHDRAW = 2,
TEH_MT_MELT = 3,
TEH_MT_COUNT = 4 /* MUST BE LAST! */
TEH_MT_REQUEST_OTHER = 0,
TEH_MT_REQUEST_DEPOSIT = 1,
TEH_MT_REQUEST_WITHDRAW = 2,
TEH_MT_REQUEST_MELT = 3,
TEH_MT_REQUEST_COUNT = 4 /* MUST BE LAST! */
};
/**
* Cipher types for which we collect metrics.
*/
enum TEH_MetricTypeRequestCipher
{
TEH_MT_CIPHER = 0,
TEH_MT_EDDSA = 2,
TEH_MT_CIPHER_COUNT = 3
};
/**
* Number of requests handled of the respective type.
*/
extern unsigned long long TEH_METRICS_num_requests[TEH_MT_COUNT];
extern unsigned long long TEH_METRICS_num_requests[TEH_MT_REQUEST_COUNT];
/**
* Number of serialization errors encountered when
* handling requests of the respective type.
*/
extern unsigned long long TEH_METRICS_num_conflict[TEH_MT_COUNT];
extern unsigned long long TEH_METRICS_num_conflict[TEH_MT_REQUEST_COUNT];
/**
* Number of signatures created by the respecitve cipher.
*/
extern unsigned long long TEH_METRICS_num_signatures[TEH_MT_CIPHER_COUNT];
/**
* Number of signatures verified by the respecitve cipher.
*/
extern unsigned long long TEH_METRICS_num_verifications[TEH_MT_CIPHER_COUNT];
/**
* Handle a "/metrics" request.

View File

@ -217,6 +217,7 @@ verify_and_execute_recoup_refresh (
}
/* check denomination signature */
TEH_METRICS_num_verifications[TEH_MT_CIPHER]++;
if (GNUNET_YES !=
TALER_test_coin_valid (coin,
&dk->denom_pub))
@ -230,6 +231,7 @@ verify_and_execute_recoup_refresh (
}
/* check recoup request signature */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_recoup_refresh_verify (&coin->denom_pub_hash,
coin_bks,
@ -328,7 +330,7 @@ verify_and_execute_recoup_refresh (
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run recoup-refresh",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&recoup_refresh_transaction,
&pc))

View File

@ -219,6 +219,7 @@ verify_and_execute_recoup (
}
/* check denomination signature */
TEH_METRICS_num_verifications[TEH_MT_CIPHER]++;
if (GNUNET_YES !=
TALER_test_coin_valid (coin,
&dk->denom_pub))
@ -232,6 +233,7 @@ verify_and_execute_recoup (
}
/* check recoup request signature */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_recoup_verify (&coin->denom_pub_hash,
coin_bks,
@ -341,7 +343,7 @@ verify_and_execute_recoup (
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run recoup",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&recoup_transaction,
&pc))

View File

@ -684,6 +684,7 @@ clean_age:
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
/* Check signature */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_link_verify (
&rrcs[i].h_denom_pub,

View File

@ -209,6 +209,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
.refund = refund
};
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_merchant_refund_verify (&refund->coin.coin_pub,
&refund->details.h_contract_terms,
@ -275,7 +276,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run refund",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&refund_transaction,
&rctx))

View File

@ -315,7 +315,7 @@ TEH_handler_reserves_get (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"get reserve history",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&reserve_history_transaction,
&rsc))

View File

@ -68,6 +68,7 @@ TEH_RESPONSE_compile_transaction_history (
&h_wire);
#if ENABLE_SANITY_CHECKS
/* internal sanity check before we hand out a bogus sig... */
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_deposit_verify (&deposit->amount_with_fee,
&deposit->deposit_fee,
@ -132,6 +133,7 @@ TEH_RESPONSE_compile_transaction_history (
const struct TALER_AgeCommitmentHash *phac = NULL;
#if ENABLE_SANITY_CHECKS
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_melt_verify (&melt->amount_with_fee,
&melt->melt_fee,
@ -185,6 +187,7 @@ TEH_RESPONSE_compile_transaction_history (
struct TALER_Amount value;
#if ENABLE_SANITY_CHECKS
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_merchant_refund_verify (coin_pub,
&refund->h_contract_terms,

View File

@ -514,7 +514,7 @@ TEH_handler_transfers_get (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"run transfers GET",
TEH_MT_OTHER,
TEH_MT_REQUEST_OTHER,
&mhd_ret,
&get_transfer_deposits,
&ctx))

View File

@ -489,6 +489,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
NULL);
}
TEH_METRICS_num_verifications[TEH_MT_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_withdraw_verify (&wc.collectable.denom_pub_hash,
&wc.collectable.amount_with_fee,
@ -525,7 +526,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"run withdraw",
TEH_MT_WITHDRAW,
TEH_MT_REQUEST_WITHDRAW,
&mhd_ret,
&withdraw_transaction,
&wc))