exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

taler-exchange-httpd_metrics.h (3601B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014--2021 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
     12 
     13   You should have received a copy of the GNU Affero General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file taler-exchange-httpd_metrics.h
     18  * @brief Handle /metrics requests
     19  * @author Christian Grothoff
     20  */
     21 #ifndef TALER_EXCHANGE_HTTPD_METRICS_H
     22 #define TALER_EXCHANGE_HTTPD_METRICS_H
     23 
     24 #include <gnunet/gnunet_util_lib.h>
     25 #include <microhttpd.h>
     26 #include "taler-exchange-httpd.h"
     27 
     28 
     29 /**
     30  * Request types for which we collect metrics.
     31  */
     32 enum TEH_MetricTypeRequest
     33 {
     34   TEH_MT_REQUEST_OTHER = 0,
     35   TEH_MT_REQUEST_DEPOSIT = 1,
     36   TEH_MT_REQUEST_WITHDRAW = 2,
     37   TEH_MT_REQUEST_MELT = 3,
     38   TEH_MT_REQUEST_PURSE_CREATE = 4,
     39   TEH_MT_REQUEST_PURSE_MERGE = 5,
     40   TEH_MT_REQUEST_RESERVE_PURSE = 6,
     41   TEH_MT_REQUEST_PURSE_DEPOSIT = 7,
     42   TEH_MT_REQUEST_IDEMPOTENT_DEPOSIT = 8,
     43   TEH_MT_REQUEST_IDEMPOTENT_WITHDRAW = 9,
     44   TEH_MT_REQUEST_IDEMPOTENT_MELT = 10,
     45   TEH_MT_REQUEST_BATCH_DEPOSIT = 11,
     46   TEH_MT_REQUEST_POLICY_FULFILLMENT = 12,
     47   TEH_MT_REQUEST_KYC_UPLOAD = 13,
     48   TEH_MT_REQUEST_COUNT = 14 /* MUST BE LAST! */
     49 };
     50 
     51 /**
     52  * Success types for which we collect metrics.
     53  */
     54 enum TEH_MetricTypeSuccess
     55 {
     56   TEH_MT_SUCCESS_DEPOSIT = 0,
     57   TEH_MT_SUCCESS_WITHDRAW = 1,
     58   TEH_MT_SUCCESS_MELT = 2,
     59   TEH_MT_SUCCESS_REFRESH_REVEAL = 3,
     60   TEH_MT_SUCCESS_WITHDRAW_REVEAL = 4,
     61   TEH_MT_SUCCESS_COUNT = 5 /* MUST BE LAST! */
     62 };
     63 
     64 /**
     65  * Cipher types for which we collect signature metrics.
     66  */
     67 enum TEH_MetricTypeSignature
     68 {
     69   TEH_MT_SIGNATURE_RSA = 0,
     70   TEH_MT_SIGNATURE_CS = 1,
     71   TEH_MT_SIGNATURE_EDDSA = 2,
     72   TEH_MT_SIGNATURE_COUNT = 3
     73 };
     74 
     75 /**
     76  * Cipher types for which we collect key exchange metrics.
     77  */
     78 enum TEH_MetricTypeKeyX
     79 {
     80   TEH_MT_KEYX_ECDH = 0,
     81   TEH_MT_KEYX_COUNT = 1
     82 };
     83 
     84 /**
     85  * Number of requests handled of the respective type.
     86  */
     87 extern unsigned long long TEH_METRICS_num_requests[TEH_MT_REQUEST_COUNT];
     88 
     89 /**
     90  * Number of successful requests handled of the respective type.
     91  */
     92 extern unsigned long long TEH_METRICS_num_success[TEH_MT_SUCCESS_COUNT];
     93 
     94 /**
     95  * Number of coins withdrawn in a withdraw request
     96  */
     97 extern unsigned long long TEH_METRICS_withdraw_num_coins;
     98 
     99 /**
    100  * Number of serialization errors encountered when
    101  * handling requests of the respective type.
    102  */
    103 extern unsigned long long TEH_METRICS_num_conflict[TEH_MT_REQUEST_COUNT];
    104 
    105 /**
    106  * Number of signatures created by the respective cipher.
    107  */
    108 extern unsigned long long TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_COUNT];
    109 
    110 /**
    111  * Number of signatures verified by the respective cipher.
    112  */
    113 extern unsigned long long TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_COUNT];
    114 
    115 /**
    116  * Number of key exchanges done with the respective cipher.
    117  */
    118 extern unsigned long long TEH_METRICS_num_keyexchanges[TEH_MT_KEYX_COUNT];
    119 
    120 /**
    121  * Handle a "/metrics" request.
    122  *
    123  * @param rc request context
    124  * @param args array of additional options (must be empty for this function)
    125  * @return MHD result code
    126  */
    127 MHD_RESULT
    128 TEH_handler_metrics (struct TEH_RequestContext *rc,
    129                      const char *const args[]);
    130 
    131 
    132 #endif