aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-12-07 21:16:38 +0100
committerChristian Grothoff <christian@grothoff.org>2021-12-07 21:16:38 +0100
commit71933dd2e9b5b66dbc72cdde9ea7b498a11db197 (patch)
tree5cb2c5f9931df442ca4ba91da33a0457476039b7 /src
parent8be9de667525a307c35e12ecacc0c3a647ccdd9b (diff)
add basic metrics collection logic
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_auditors.c1
-rw-r--r--src/exchange/taler-exchange-httpd_db.c21
-rw-r--r--src/exchange/taler-exchange-httpd_db.h3
-rw-r--r--src/exchange/taler-exchange-httpd_deposit.c1
-rw-r--r--src/exchange/taler-exchange-httpd_deposits_get.c1
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-check.c1
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-proof.c1
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-wallet.c1
-rw-r--r--src/exchange/taler-exchange-httpd_link.c1
-rw-r--r--src/exchange/taler-exchange-httpd_management_auditors.c1
-rw-r--r--src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c1
-rw-r--r--src/exchange/taler-exchange-httpd_management_post_keys.c1
-rw-r--r--src/exchange/taler-exchange-httpd_management_wire_disable.c1
-rw-r--r--src/exchange/taler-exchange-httpd_management_wire_enable.c1
-rw-r--r--src/exchange/taler-exchange-httpd_management_wire_fees.c1
-rw-r--r--src/exchange/taler-exchange-httpd_melt.c1
-rw-r--r--src/exchange/taler-exchange-httpd_metrics.c5
-rw-r--r--src/exchange/taler-exchange-httpd_metrics.h28
-rw-r--r--src/exchange/taler-exchange-httpd_recoup.c1
-rw-r--r--src/exchange/taler-exchange-httpd_refreshes_reveal.c3
-rw-r--r--src/exchange/taler-exchange-httpd_refund.c1
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_get.c1
-rw-r--r--src/exchange/taler-exchange-httpd_transfers_get.c1
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c1
24 files changed, 63 insertions, 16 deletions
diff --git a/src/exchange/taler-exchange-httpd_auditors.c b/src/exchange/taler-exchange-httpd_auditors.c
index bf4a9b2c0..1b8af311c 100644
--- a/src/exchange/taler-exchange-httpd_auditors.c
+++ b/src/exchange/taler-exchange-httpd_auditors.c
@@ -216,6 +216,7 @@ TEH_handler_auditors (
return MHD_YES; /* failure */
ret = TEH_DB_run_transaction (connection,
"add auditor denom sig",
+ TEH_MT_OTHER,
&res,
&add_auditor_denom_sig,
&awc);
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 08b578445..da495517a 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -24,6 +24,7 @@
#include <gnunet/gnunet_json_lib.h>
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
+#include "taler-exchange-httpd_db.h"
#include "taler-exchange-httpd_responses.h"
@@ -113,25 +114,10 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
}
-/**
- * Run a database transaction for @a connection.
- * Starts a transaction and calls @a cb. Upon success,
- * attempts to commit the transaction. Upon soft failures,
- * retries @a cb a few times. Upon hard or persistent soft
- * errors, generates an error message for @a connection.
- *
- * @param connection MHD connection to run @a cb for, can be NULL
- * @param name name of the transaction (for debugging)
- * @param[out] mhd_ret set to MHD response code, if transaction failed;
- * NULL if we are not running with a @a connection and thus
- * must not queue MHD replies
- * @param cb callback implementing transaction logic
- * @param cb_cls closure for @a cb, must be read-only!
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
- */
enum GNUNET_GenericReturnValue
TEH_DB_run_transaction (struct MHD_Connection *connection,
const char *name,
+ enum TEH_MetricType mt,
MHD_RESULT *mhd_ret,
TEH_DB_TransactionCallback cb,
void *cb_cls)
@@ -149,6 +135,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
NULL);
return GNUNET_SYSERR;
}
+ GNUNET_assert (mt < TEH_MT_COUNT);
+ TEH_METRICS_num_requests[mt]++;
for (unsigned int retries = 0;
retries < MAX_TRANSACTION_COMMIT_RETRIES;
retries++)
@@ -190,6 +178,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
(-1 == (int) *mhd_ret) );
if (0 <= qs)
return GNUNET_OK;
+ TEH_METRICS_num_conflict[mt]++;
}
TALER_LOG_ERROR ("Transaction `%s' commit failed %u times\n",
name,
diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h
index c115981d3..83302235d 100644
--- a/src/exchange/taler-exchange-httpd_db.h
+++ b/src/exchange/taler-exchange-httpd_db.h
@@ -23,6 +23,7 @@
#include <microhttpd.h>
#include "taler_exchangedb_plugin.h"
+#include "taler-exchange-httpd_metrics.h"
#include <gnunet/gnunet_mhd_compat.h>
@@ -69,6 +70,7 @@ typedef enum GNUNET_DB_QueryStatus
*
* @param connection MHD connection to run @a cb for, can be NULL
* @param name name of the transaction (for debugging)
+ * @param mt type of the requests, for metric generation
* @param[out] mhd_ret set to MHD response code, if transaction failed (returned #GNUNET_SYSERR);
* NULL if we are not running with a @a connection and thus
* must not queue MHD replies
@@ -79,6 +81,7 @@ typedef enum GNUNET_DB_QueryStatus
enum GNUNET_GenericReturnValue
TEH_DB_run_transaction (struct MHD_Connection *connection,
const char *name,
+ enum TEH_MetricType mt,
MHD_RESULT *mhd_ret,
TEH_DB_TransactionCallback cb,
void *cb_cls);
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c
index 6b651f40e..5534c402e 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -497,6 +497,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"execute deposit",
+ TEH_MT_DEPOSIT,
&mhd_ret,
&deposit_transaction,
&dc))
diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c b/src/exchange/taler-exchange-httpd_deposits_get.c
index d981a8dd9..3db177015 100644
--- a/src/exchange/taler-exchange-httpd_deposits_get.c
+++ b/src/exchange/taler-exchange-httpd_deposits_get.c
@@ -246,6 +246,7 @@ handle_track_transaction_request (
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"handle deposits GET",
+ TEH_MT_OTHER,
&mhd_ret,
&deposits_get_transaction,
&ctx))
diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c
index 76d094817..1edbbf2aa 100644
--- a/src/exchange/taler-exchange-httpd_kyc-check.c
+++ b/src/exchange/taler-exchange-httpd_kyc-check.c
@@ -351,6 +351,7 @@ TEH_handler_kyc_check (
(void) GNUNET_TIME_round_abs (&now);
ret = TEH_DB_run_transaction (rc->connection,
"kyc check",
+ TEH_MT_OTHER,
&res,
&kyc_check,
kyp);
diff --git a/src/exchange/taler-exchange-httpd_kyc-proof.c b/src/exchange/taler-exchange-httpd_kyc-proof.c
index 6bd98abfe..24ddfc74d 100644
--- a/src/exchange/taler-exchange-httpd_kyc-proof.c
+++ b/src/exchange/taler-exchange-httpd_kyc-proof.c
@@ -678,6 +678,7 @@ TEH_handler_kyc_proof (
ret = TEH_DB_run_transaction (kpc->rc->connection,
"check proof kyc",
+ TEH_MT_OTHER,
&res,
&persist_kyc_ok,
kpc);
diff --git a/src/exchange/taler-exchange-httpd_kyc-wallet.c b/src/exchange/taler-exchange-httpd_kyc-wallet.c
index 3db174bf0..4062f9305 100644
--- a/src/exchange/taler-exchange-httpd_kyc-wallet.c
+++ b/src/exchange/taler-exchange-httpd_kyc-wallet.c
@@ -140,6 +140,7 @@ TEH_handler_kyc_wallet (
0);
ret = TEH_DB_run_transaction (rc->connection,
"check wallet kyc",
+ TEH_MT_OTHER,
&res,
&wallet_kyc_check,
&krc);
diff --git a/src/exchange/taler-exchange-httpd_link.c b/src/exchange/taler-exchange-httpd_link.c
index 3393e0683..d3c0d6a5a 100644
--- a/src/exchange/taler-exchange-httpd_link.c
+++ b/src/exchange/taler-exchange-httpd_link.c
@@ -193,6 +193,7 @@ TEH_handler_link (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"run link",
+ TEH_MT_OTHER,
&mhd_ret,
&link_transaction,
&ctx))
diff --git a/src/exchange/taler-exchange-httpd_management_auditors.c b/src/exchange/taler-exchange-httpd_management_auditors.c
index d782618f1..f9092c53b 100644
--- a/src/exchange/taler-exchange-httpd_management_auditors.c
+++ b/src/exchange/taler-exchange-httpd_management_auditors.c
@@ -187,6 +187,7 @@ TEH_handler_management_auditors (
ret = TEH_DB_run_transaction (connection,
"add auditor",
+ TEH_MT_OTHER,
&res,
&add_auditor,
&aac);
diff --git a/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c b/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c
index 7bf191f47..8b31fb139 100644
--- a/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c
+++ b/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c
@@ -176,6 +176,7 @@ TEH_handler_management_auditors_AP_disable (
ret = TEH_DB_run_transaction (connection,
"del auditor",
+ TEH_MT_OTHER,
&res,
&del_auditor,
&dac);
diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c
index 86b17cb3d..ad4cd3c04 100644
--- a/src/exchange/taler-exchange-httpd_management_post_keys.c
+++ b/src/exchange/taler-exchange-httpd_management_post_keys.c
@@ -454,6 +454,7 @@ TEH_handler_management_post_keys (
res = TEH_DB_run_transaction (connection,
"add keys",
+ TEH_MT_OTHER,
&ret,
&add_keys,
&akc);
diff --git a/src/exchange/taler-exchange-httpd_management_wire_disable.c b/src/exchange/taler-exchange-httpd_management_wire_disable.c
index 17bd7273f..2d37a7204 100644
--- a/src/exchange/taler-exchange-httpd_management_wire_disable.c
+++ b/src/exchange/taler-exchange-httpd_management_wire_disable.c
@@ -177,6 +177,7 @@ TEH_handler_management_post_wire_disable (
res = TEH_DB_run_transaction (connection,
"del wire",
+ TEH_MT_OTHER,
&ret,
&del_wire,
&awc);
diff --git a/src/exchange/taler-exchange-httpd_management_wire_enable.c b/src/exchange/taler-exchange-httpd_management_wire_enable.c
index 4bad41b40..165c5183d 100644
--- a/src/exchange/taler-exchange-httpd_management_wire_enable.c
+++ b/src/exchange/taler-exchange-httpd_management_wire_enable.c
@@ -212,6 +212,7 @@ TEH_handler_management_post_wire (
res = TEH_DB_run_transaction (connection,
"add wire",
+ TEH_MT_OTHER,
&ret,
&add_wire,
&awc);
diff --git a/src/exchange/taler-exchange-httpd_management_wire_fees.c b/src/exchange/taler-exchange-httpd_management_wire_fees.c
index 4272a2d06..180149042 100644
--- a/src/exchange/taler-exchange-httpd_management_wire_fees.c
+++ b/src/exchange/taler-exchange-httpd_management_wire_fees.c
@@ -221,6 +221,7 @@ TEH_handler_management_post_wire_fees (
res = TEH_DB_run_transaction (connection,
"add wire fee",
+ TEH_MT_OTHER,
&ret,
&add_fee,
&afc);
diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c
index 3dbff43a8..e2e343711 100644
--- a/src/exchange/taler-exchange-httpd_melt.c
+++ b/src/exchange/taler-exchange-httpd_melt.c
@@ -432,6 +432,7 @@ handle_melt (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run melt",
+ TEH_MT_MELT,
&mhd_ret,
&melt_transaction,
rmc))
diff --git a/src/exchange/taler-exchange-httpd_metrics.c b/src/exchange/taler-exchange-httpd_metrics.c
index 953210926..d3f1f02d8 100644
--- a/src/exchange/taler-exchange-httpd_metrics.c
+++ b/src/exchange/taler-exchange-httpd_metrics.c
@@ -29,6 +29,11 @@
#include <jansson.h>
+unsigned long long TEH_METRICS_num_requests[TEH_MT_COUNT];
+
+unsigned long long TEH_METRICS_num_conflict[TEH_MT_COUNT];
+
+
MHD_RESULT
TEH_handler_metrics (struct TEH_RequestContext *rc,
const char *const args[])
diff --git a/src/exchange/taler-exchange-httpd_metrics.h b/src/exchange/taler-exchange-httpd_metrics.h
index 399a17670..39e463169 100644
--- a/src/exchange/taler-exchange-httpd_metrics.h
+++ b/src/exchange/taler-exchange-httpd_metrics.h
@@ -27,6 +27,34 @@
/**
+ * Request types for which we collect metrics.
+ */
+enum TEH_MetricType
+{
+ TEH_MT_OTHER = 0,
+ TEH_MT_DEPOSIT = 1,
+ TEH_MT_WITHDRAW = 2,
+ TEH_MT_MELT = 3,
+ TEH_MT_REVEAL_PRECHECK = 4,
+ TEH_MT_REVEAL = 5,
+ TEH_MT_REVEAL_PERSIST = 6,
+ TEH_MT_COUNT = 7 /* MUST BE LAST! */
+};
+
+
+/**
+ * Number of requests handled of the respective type.
+ */
+extern unsigned long long TEH_METRICS_num_requests[TEH_MT_COUNT];
+
+/**
+ * Number of serialization errors encountered when
+ * handling requests of the respective type.
+ */
+extern unsigned long long TEH_METRICS_num_conflict[TEH_MT_COUNT];
+
+
+/**
* Handle a "/metrics" request.
*
* @param rc request context
diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c
index b5074ce35..7ea345b87 100644
--- a/src/exchange/taler-exchange-httpd_recoup.c
+++ b/src/exchange/taler-exchange-httpd_recoup.c
@@ -477,6 +477,7 @@ verify_and_execute_recoup (
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run recoup",
+ TEH_MT_OTHER,
&mhd_ret,
&recoup_transaction,
&pc))
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 4631a2b92..08587a516 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -724,6 +724,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
if ( (GNUNET_OK ==
TEH_DB_run_transaction (connection,
"reveal pre-check",
+ TEH_MT_REVEAL_PRECHECK,
&ret,
&refreshes_reveal_preflight,
rctx)) &&
@@ -745,6 +746,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run reveal",
+ TEH_MT_REVEAL,
&ret,
&refreshes_reveal_transaction,
rctx))
@@ -756,6 +758,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,
if (GNUNET_OK ==
TEH_DB_run_transaction (connection,
"persist reveal",
+ TEH_MT_REVEAL_PERSIST,
&ret,
&refreshes_reveal_persist,
rctx))
diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c
index be8a88df2..a1ef50a32 100644
--- a/src/exchange/taler-exchange-httpd_refund.c
+++ b/src/exchange/taler-exchange-httpd_refund.c
@@ -447,6 +447,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
"run refund",
+ TEH_MT_OTHER,
&mhd_ret,
&refund_transaction,
(void *) refund))
diff --git a/src/exchange/taler-exchange-httpd_reserves_get.c b/src/exchange/taler-exchange-httpd_reserves_get.c
index 3b8354215..80c992e61 100644
--- a/src/exchange/taler-exchange-httpd_reserves_get.c
+++ b/src/exchange/taler-exchange-httpd_reserves_get.c
@@ -315,6 +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,
&mhd_ret,
&reserve_history_transaction,
&rsc))
diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c
index e63acdc2a..38a5c211d 100644
--- a/src/exchange/taler-exchange-httpd_transfers_get.c
+++ b/src/exchange/taler-exchange-httpd_transfers_get.c
@@ -515,6 +515,7 @@ TEH_handler_transfers_get (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"run transfers GET",
+ TEH_MT_OTHER,
&mhd_ret,
&get_transfer_deposits,
&ctx))
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index 8540fca4b..9a45271bb 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -521,6 +521,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
if (GNUNET_OK !=
TEH_DB_run_transaction (rc->connection,
"run withdraw",
+ TEH_MT_WITHDRAW,
&mhd_ret,
&withdraw_transaction,
&wc))