Make common macros extendable

This commit is contained in:
Amos Bird 2023-06-30 14:48:20 +08:00
parent 376c903da9
commit d8e87f6c1d
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
4 changed files with 27 additions and 5 deletions

View File

@ -2,7 +2,7 @@
/// Available metrics. Add something here as you wish. /// Available metrics. Add something here as you wish.
#define APPLY_FOR_METRICS(M) \ #define APPLY_FOR_BUILTIN_METRICS(M) \
M(Query, "Number of executing queries") \ M(Query, "Number of executing queries") \
M(Merge, "Number of executing background merges") \ M(Merge, "Number of executing background merges") \
M(Move, "Number of currently executing moves") \ M(Move, "Number of currently executing moves") \
@ -200,7 +200,13 @@
M(MergeTreeReadTaskRequestsSent, "The current number of callback requests in flight from the remote server back to the initiator server to choose the read task (for MergeTree tables). Measured on the remote server side.") \ M(MergeTreeReadTaskRequestsSent, "The current number of callback requests in flight from the remote server back to the initiator server to choose the read task (for MergeTree tables). Measured on the remote server side.") \
M(MergeTreeAllRangesAnnouncementsSent, "The current number of announcement being sent in flight from the remote server to the initiator server about the set of data parts (for MergeTree tables). Measured on the remote server side.") \ M(MergeTreeAllRangesAnnouncementsSent, "The current number of announcement being sent in flight from the remote server to the initiator server about the set of data parts (for MergeTree tables). Measured on the remote server side.") \
M(CreatedTimersInQueryProfiler, "Number of Created thread local timers in QueryProfiler") \ M(CreatedTimersInQueryProfiler, "Number of Created thread local timers in QueryProfiler") \
M(ActiveTimersInQueryProfiler, "Number of Active thread local timers in QueryProfiler") M(ActiveTimersInQueryProfiler, "Number of Active thread local timers in QueryProfiler") \
#ifdef APPLY_FOR_EXTERNAL_METRICS
#define APPLY_FOR_METRICS(M) APPLY_FOR_BUILTIN_METRICS(M) APPLY_FOR_EXTERNAL_METRICS(M)
#else
#define APPLY_FOR_METRICS(M) APPLY_FOR_BUILTIN_METRICS(M)
#endif
namespace CurrentMetrics namespace CurrentMetrics
{ {

View File

@ -13,7 +13,7 @@
* - system.errors table * - system.errors table
*/ */
#define APPLY_FOR_ERROR_CODES(M) \ #define APPLY_FOR_BUILTIN_ERROR_CODES(M) \
M(0, OK) \ M(0, OK) \
M(1, UNSUPPORTED_METHOD) \ M(1, UNSUPPORTED_METHOD) \
M(2, UNSUPPORTED_PARAMETER) \ M(2, UNSUPPORTED_PARAMETER) \
@ -589,6 +589,12 @@
M(1002, UNKNOWN_EXCEPTION) \ M(1002, UNKNOWN_EXCEPTION) \
/* See END */ /* See END */
#ifdef APPLY_FOR_EXTERNAL_ERROR_CODES
#define APPLY_FOR_ERROR_CODES(M) APPLY_FOR_BUILTIN_ERROR_CODES(M) APPLY_FOR_EXTERNAL_ERROR_CODES(M)
#else
#define APPLY_FOR_ERROR_CODES(M) APPLY_FOR_BUILTIN_ERROR_CODES(M)
#endif
namespace DB namespace DB
{ {
namespace ErrorCodes namespace ErrorCodes

View File

@ -4,7 +4,7 @@
/// Available events. Add something here as you wish. /// Available events. Add something here as you wish.
#define APPLY_FOR_EVENTS(M) \ #define APPLY_FOR_BUILTIN_EVENTS(M) \
M(Query, "Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries.") \ M(Query, "Number of queries to be interpreted and potentially executed. Does not include queries that failed to parse or were rejected due to AST size limits, quota limits or limits on the number of simultaneously running queries. May include internal queries initiated by ClickHouse itself. Does not count subqueries.") \
M(SelectQuery, "Same as Query, but only for SELECT queries.") \ M(SelectQuery, "Same as Query, but only for SELECT queries.") \
M(InsertQuery, "Same as Query, but only for INSERT queries.") \ M(InsertQuery, "Same as Query, but only for INSERT queries.") \
@ -536,6 +536,11 @@ The server successfully detected this situation and will download merged part fr
M(LogError, "Number of log messages with level Error") \ M(LogError, "Number of log messages with level Error") \
M(LogFatal, "Number of log messages with level Fatal") \ M(LogFatal, "Number of log messages with level Fatal") \
#ifdef APPLY_FOR_EXTERNAL_EVENTS
#define APPLY_FOR_EVENTS(M) APPLY_FOR_BUILTIN_EVENTS(M) APPLY_FOR_EXTERNAL_EVENTS(M)
#else
#define APPLY_FOR_EVENTS(M) APPLY_FOR_BUILTIN_EVENTS(M)
#endif
namespace ProfileEvents namespace ProfileEvents
{ {

View File

@ -2,9 +2,14 @@
#include <Common/ExternalLoaderStatus.h> #include <Common/ExternalLoaderStatus.h>
/// Available status. Add something here as you wish. /// Available status. Add something here as you wish.
#define APPLY_FOR_STATUS(M) \ #define APPLY_FOR_BUILTIN_STATUS(M) \
M(DictionaryStatus, "Dictionary Status.", DB::getStatusEnumAllPossibleValues()) \ M(DictionaryStatus, "Dictionary Status.", DB::getStatusEnumAllPossibleValues()) \
#ifdef APPLY_FOR_EXTERNAL_STATUS
#define APPLY_FOR_STATUS(M) APPLY_FOR_BUILTIN_STATUS(M) APPLY_FOR_EXTERNAL_STATUS(M)
#else
#define APPLY_FOR_STATUS(M) APPLY_FOR_BUILTIN_STATUS(M)
#endif
namespace CurrentStatusInfo namespace CurrentStatusInfo
{ {