add core success count metrics

This commit is contained in:
Christian Grothoff 2022-06-08 15:47:47 +02:00
parent f2e2c5c9d8
commit 7700f6ff88
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
7 changed files with 63 additions and 13 deletions

View File

@ -273,6 +273,7 @@ batch_withdraw_transaction (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }
TEH_METRICS_num_success[TEH_MT_SUCCESS_BATCH_WITHDRAW]++;
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
} }

View File

@ -203,6 +203,7 @@ deposit_transaction (void *cls,
&dc->deposit->coin.coin_pub); &dc->deposit->coin.coin_pub);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
TEH_METRICS_num_success[TEH_MT_SUCCESS_DEPOSIT]++;
return qs; return qs;
} }

View File

@ -201,6 +201,7 @@ melt_transaction (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
/* All good, commit, final response will be generated by caller */ /* All good, commit, final response will be generated by caller */
TEH_METRICS_num_success[TEH_MT_SUCCESS_MELT]++;
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
} }

View File

@ -41,6 +41,9 @@ unsigned long long TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_COUNT];
unsigned long long TEH_METRICS_num_keyexchanges[TEH_MT_KEYX_COUNT]; unsigned long long TEH_METRICS_num_keyexchanges[TEH_MT_KEYX_COUNT];
unsigned long long TEH_METRICS_num_success[TEH_MT_SUCCESS_COUNT];
MHD_RESULT MHD_RESULT
TEH_handler_metrics (struct TEH_RequestContext *rc, TEH_handler_metrics (struct TEH_RequestContext *rc,
const char *const args[]) const char *const args[])
@ -51,6 +54,11 @@ TEH_handler_metrics (struct TEH_RequestContext *rc,
(void) args; (void) args;
GNUNET_asprintf (&reply, GNUNET_asprintf (&reply,
"taler_exchange_success_transactions{type=\"%s\"} %llu\n"
"taler_exchange_success_transactions{type=\"%s\"} %llu\n"
"taler_exchange_success_transactions{type=\"%s\"} %llu\n"
"taler_exchange_success_transactions{type=\"%s\"} %llu\n"
"taler_exchange_success_transactions{type=\"%s\"} %llu\n"
"# HELP taler_exchange_serialization_failures " "# HELP taler_exchange_serialization_failures "
" number of database serialization errors by type\n" " number of database serialization errors by type\n"
"# TYPE taler_exchange_serialization_failures counter\n" "# TYPE taler_exchange_serialization_failures counter\n"
@ -91,6 +99,16 @@ TEH_handler_metrics (struct TEH_RequestContext *rc,
" number of coins withdrawn in a batch-withdraw request\n" " number of coins withdrawn in a batch-withdraw request\n"
"# TYPE taler_exchange_batch_withdraw_num_coins counter\n" "# TYPE taler_exchange_batch_withdraw_num_coins counter\n"
"taler_exchange_batch_withdraw_num_coins{} %llu\n", "taler_exchange_batch_withdraw_num_coins{} %llu\n",
"deposit",
TEH_METRICS_num_success[TEH_MT_SUCCESS_DEPOSIT],
"withdraw",
TEH_METRICS_num_success[TEH_MT_SUCCESS_WITHDRAW],
"batch-withdraw",
TEH_METRICS_num_success[TEH_MT_SUCCESS_BATCH_WITHDRAW],
"melt",
TEH_METRICS_num_success[TEH_MT_SUCCESS_MELT],
"refresh-reveal",
TEH_METRICS_num_success[TEH_MT_SUCCESS_REFRESH_REVEAL],
"other", "other",
TEH_METRICS_num_conflict[TEH_MT_REQUEST_OTHER], TEH_METRICS_num_conflict[TEH_MT_REQUEST_OTHER],
"deposit", "deposit",

View File

@ -46,6 +46,19 @@ enum TEH_MetricTypeRequest
TEH_MT_REQUEST_COUNT = 12 /* MUST BE LAST! */ TEH_MT_REQUEST_COUNT = 12 /* MUST BE LAST! */
}; };
/**
* Success types for which we collect metrics.
*/
enum TEH_MetricTypeSuccess
{
TEH_MT_SUCCESS_DEPOSIT = 0,
TEH_MT_SUCCESS_WITHDRAW = 1,
TEH_MT_SUCCESS_BATCH_WITHDRAW = 2,
TEH_MT_SUCCESS_MELT = 3,
TEH_MT_SUCCESS_REFRESH_REVEAL = 4,
TEH_MT_SUCCESS_COUNT = 5 /* MUST BE LAST! */
};
/** /**
* Cipher types for which we collect signature metrics. * Cipher types for which we collect signature metrics.
*/ */
@ -71,6 +84,11 @@ enum TEH_MetricTypeKeyX
*/ */
extern unsigned long long TEH_METRICS_num_requests[TEH_MT_REQUEST_COUNT]; extern unsigned long long TEH_METRICS_num_requests[TEH_MT_REQUEST_COUNT];
/**
* Number of successful requests handled of the respective type.
*/
extern unsigned long long TEH_METRICS_num_success[TEH_MT_SUCCESS_COUNT];
/** /**
* Number of coins withdrawn in a batch-withdraw request * Number of coins withdrawn in a batch-withdraw request
*/ */

View File

@ -428,12 +428,13 @@ check_commitment (struct RevealContext *rctx,
* @return MHD result code * @return MHD result code
*/ */
static MHD_RESULT static MHD_RESULT
resolve_refreshes_reveal_denominations (struct MHD_Connection *connection, resolve_refreshes_reveal_denominations (
struct RevealContext *rctx, struct MHD_Connection *connection,
const json_t *link_sigs_json, struct RevealContext *rctx,
const json_t *new_denoms_h_json, const json_t *link_sigs_json,
const json_t *old_age_commitment_json, const json_t *new_denoms_h_json,
const json_t *coin_evs) const json_t *old_age_commitment_json,
const json_t *coin_evs)
{ {
unsigned int num_fresh_coins = json_array_size (new_denoms_h_json); unsigned int num_fresh_coins = json_array_size (new_denoms_h_json);
/* We know num_fresh_coins is bounded by #TALER_MAX_FRESH_COINS, so this is safe */ /* We know num_fresh_coins is bounded by #TALER_MAX_FRESH_COINS, so this is safe */
@ -771,6 +772,8 @@ clean_age:
for (unsigned int r = 0; r<MAX_TRANSACTION_COMMIT_RETRIES; r++) for (unsigned int r = 0; r<MAX_TRANSACTION_COMMIT_RETRIES; r++)
{ {
bool changed;
/* Persist operation result in DB */ /* Persist operation result in DB */
if (GNUNET_OK != if (GNUNET_OK !=
TEH_plugin->start (TEH_plugin->cls, TEH_plugin->start (TEH_plugin->cls,
@ -789,13 +792,14 @@ clean_age:
rrc->blinded_planchet = rcds[i].blinded_planchet; rrc->blinded_planchet = rcds[i].blinded_planchet;
} }
qs = TEH_plugin->insert_refresh_reveal (TEH_plugin->cls, qs = TEH_plugin->insert_refresh_reveal (
melt_serial_id, TEH_plugin->cls,
num_fresh_coins, melt_serial_id,
rrcs, num_fresh_coins,
TALER_CNC_KAPPA - 1, rrcs,
rctx->transfer_privs, TALER_CNC_KAPPA - 1,
&rctx->gamma_tp); rctx->transfer_privs,
&rctx->gamma_tp);
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
{ {
TEH_plugin->rollback (TEH_plugin->cls); TEH_plugin->rollback (TEH_plugin->cls);
@ -812,9 +816,14 @@ clean_age:
"insert_refresh_reveal"); "insert_refresh_reveal");
goto cleanup; goto cleanup;
} }
changed = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
qs = TEH_plugin->commit (TEH_plugin->cls); qs = TEH_plugin->commit (TEH_plugin->cls);
if (qs >= 0) if (qs >= 0)
{
if (changed)
TEH_METRICS_num_success[TEH_MT_SUCCESS_REFRESH_REVEAL]++;
break; /* success */ break; /* success */
}
if (GNUNET_DB_STATUS_HARD_ERROR == qs) if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -194,6 +194,8 @@ withdraw_transaction (void *cls,
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
TEH_METRICS_num_success[TEH_MT_SUCCESS_BATCH_WITHDRAW]++;
return qs; return qs;
} }