Allow to choose xmon env in C++ apps

This commit is contained in:
Francesco Mazzoli
2023-09-18 11:55:46 +00:00
parent 591df97c44
commit 77ac15af8d
6 changed files with 23 additions and 1 deletions
+1
View File
@@ -818,6 +818,7 @@ void runCDC(const std::string& dbDir, const CDCOptions& options) {
if (xmon) {
XmonConfig config;
config.appInstance = "cdc";
config.prod = options.xmonProd;
Xmon::spawn(*undertaker, std::make_unique<Xmon>(logger, xmon, config));
}
+1
View File
@@ -15,6 +15,7 @@ struct CDCOptions {
bool syslog = false;
Duration shardTimeout = 100_ms;
bool xmon = false;
bool xmonProd = false;
// at 1ms per request it's 10 seconds worth of requests.
uint64_t maximumEnqueuedRequests = 10000;
bool metrics = false;
+9
View File
@@ -124,6 +124,15 @@ int main(int argc, char** argv) {
options.shardTimeout = Duration(ms * 1'000'000);
} else if (arg == "-xmon") {
options.xmon = true;
std::string xmonEnv = getNextArg();
if (xmonEnv == "qa") {
options.xmonProd = false;
} else if (xmonEnv == "prod") {
options.xmonProd = true;
} else {
fprintf(stderr, "Invalid xmon env %s", xmonEnv.c_str());
dieWithUsage();
}
} else if (arg == "-metrics") {
options.metrics = true;
} else {
+1
View File
@@ -562,6 +562,7 @@ void runShard(ShardId shid, const std::string& dbDir, const ShardOptions& option
ss << std::setw(3) << std::setfill('0') << shid;
config.appInstance = "shard:" + ss.str();
}
config.prod = options.xmonProd;
Xmon::spawn(*undertaker, std::make_unique<Xmon>(logger, xmon, config));
}
+1
View File
@@ -25,6 +25,7 @@ struct ShardOptions {
double simulateOutgoingPacketDrop = 0.0;
bool syslog = false;
bool xmon = false;
bool xmonProd = false;
bool metrics = false;
Duration transientDeadlineInterval = DEFAULT_DEADLINE_INTERVAL;
};
+10 -1
View File
@@ -35,7 +35,7 @@ static void usage(const char* binary) {
fprintf(stderr, " Drop given ratio of packets on arrival.\n");
fprintf(stderr, " -outgoing-packet-drop [0, 1)\n");
fprintf(stderr, " Drop given ratio of packets after processing them.\n");
fprintf(stderr, " -xmon\n");
fprintf(stderr, " -xmon qa|prod\n");
fprintf(stderr, " Enable Xmon alerts.\n");
fprintf(stderr, " -metrics\n");
fprintf(stderr, " Enable metrics.\n");
@@ -162,6 +162,15 @@ int main(int argc, char** argv) {
options.syslog = true;
} else if (arg == "-xmon") {
options.xmon = true;
std::string xmonEnv = getNextArg();
if (xmonEnv == "qa") {
options.xmonProd = false;
} else if (xmonEnv == "prod") {
options.xmonProd = true;
} else {
fprintf(stderr, "Invalid xmon env %s", xmonEnv.c_str());
dieWithUsage();
}
} else if (arg == "-metrics") {
options.metrics = true;
} else if (arg == "-transient-deadline-interval") {