mirror of
https://github.com/lubosz/overte.git
synced 2025-04-17 00:57:44 +02:00
Review fixes
This commit is contained in:
parent
da5e4d3cfc
commit
303f10dada
3 changed files with 27 additions and 25 deletions
|
@ -89,6 +89,7 @@ int OctreeServer::_shortProcessWait = 0;
|
|||
int OctreeServer::_noProcessWait = 0;
|
||||
|
||||
static const QString PERSIST_FILE_DOWNLOAD_PATH = "/models.json.gz";
|
||||
static const double NANOSECONDS_PER_SECOND = 1000000.0;;
|
||||
|
||||
|
||||
void OctreeServer::resetSendingStats() {
|
||||
|
@ -1344,9 +1345,8 @@ QString OctreeServer::getUptime() {
|
|||
return formattedUptime;
|
||||
}
|
||||
|
||||
double OctreeServer::getUptimeSeconds()
|
||||
{
|
||||
return (usecTimestampNow() - _startedUSecs) / 1000000.0;
|
||||
double OctreeServer::getUptimeSeconds() {
|
||||
return (usecTimestampNow() - _startedUSecs) / NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
|
||||
QString OctreeServer::getFileLoadTime() {
|
||||
|
@ -1391,9 +1391,8 @@ QString OctreeServer::getFileLoadTime() {
|
|||
return result;
|
||||
}
|
||||
|
||||
double OctreeServer::getFileLoadTimeSeconds()
|
||||
{
|
||||
return getLoadElapsedTime() / 1000000.0;
|
||||
double OctreeServer::getFileLoadTimeSeconds() {
|
||||
return getLoadElapsedTime() / NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
|
||||
QString OctreeServer::getConfiguration() {
|
||||
|
|
|
@ -67,6 +67,9 @@ Q_LOGGING_CATEGORY(domain_server_ice, "hifi.domain_server.ice")
|
|||
|
||||
const QString ACCESS_TOKEN_KEY_PATH = "metaverse.access_token";
|
||||
const QString DomainServer::REPLACEMENT_FILE_EXTENSION = ".replace";
|
||||
const int MIN_PORT = 1;
|
||||
const int MAX_PORT = 65535;
|
||||
|
||||
|
||||
int const DomainServer::EXIT_CODE_REBOOT = 234923;
|
||||
|
||||
|
@ -3052,7 +3055,7 @@ void DomainServer::initializeExporter()
|
|||
bool isExporterEnabled = _settingsManager.valueOrDefaultValueForKeyPath(ENABLE_EXPORTER).toBool();
|
||||
int exporterPort = _settingsManager.valueOrDefaultValueForKeyPath(EXPORTER_PORT).toInt();
|
||||
|
||||
if (exporterPort < 1 || exporterPort > 65535) {
|
||||
if (exporterPort < MIN_PORT || exporterPort > MAX_PORT) {
|
||||
qCWarning(domain_server) << "Prometheus exporter port " << exporterPort << " is out of range.";
|
||||
isExporterEnabled = false;
|
||||
}
|
||||
|
|
|
@ -341,16 +341,16 @@ void DomainServerExporter::generateMetricsFromJson(QTextStream& stream,
|
|||
QHash<QString, QString> labels,
|
||||
const QJsonObject& obj) {
|
||||
for (auto iter = obj.constBegin(); iter != obj.constEnd(); ++iter) {
|
||||
auto key = escapeName(iter.key());
|
||||
auto val = iter.value();
|
||||
auto metric_name = path + "_" + key;
|
||||
auto escaped_key = escapeName(iter.key());
|
||||
auto metric_value = iter.value();
|
||||
auto metric_name = path + "_" + escaped_key;
|
||||
auto orig_metric_name = original_path + " -> " + iter.key();
|
||||
|
||||
if (val.isObject()) {
|
||||
if (metric_value.isObject()) {
|
||||
QUuid possible_uuid = QUuid::fromString(iter.key());
|
||||
|
||||
if (possible_uuid.isNull()) {
|
||||
generateMetricsFromJson(stream, original_path + " -> " + iter.key(), path + "_" + key, labels,
|
||||
generateMetricsFromJson(stream, original_path + " -> " + iter.key(), path + "_" + escaped_key, labels,
|
||||
iter.value().toObject());
|
||||
} else {
|
||||
labels.insert("uuid", possible_uuid.toString(QUuid::WithoutBraces));
|
||||
|
@ -367,10 +367,10 @@ void DomainServerExporter::generateMetricsFromJson(QTextStream& stream,
|
|||
bool conversion_ok = false;
|
||||
double converted = 0;
|
||||
|
||||
if (val.isString()) {
|
||||
if (metric_value.isString()) {
|
||||
// Prometheus only deals with numeric values. See if this string contains a valid one
|
||||
|
||||
QString tmp = val.toString();
|
||||
QString tmp = metric_value.toString();
|
||||
converted = tmp.toDouble(&conversion_ok);
|
||||
|
||||
if (!conversion_ok) {
|
||||
|
@ -407,7 +407,7 @@ void DomainServerExporter::generateMetricsFromJson(QTextStream& stream,
|
|||
<< "Type for metric " << orig_metric_name << " (" << metric_name << ") not known.";
|
||||
}
|
||||
|
||||
stream << path << "_" << key;
|
||||
stream << path << "_" << escaped_key;
|
||||
if (!labels.isEmpty()) {
|
||||
stream << "{";
|
||||
|
||||
|
@ -421,12 +421,12 @@ void DomainServerExporter::generateMetricsFromJson(QTextStream& stream,
|
|||
stream << ",";
|
||||
}
|
||||
|
||||
QString value = iter.value();
|
||||
value.replace("\\", "\\\\");
|
||||
value.replace("\"", "\\\"");
|
||||
value.replace("\n", "\\\n");
|
||||
QString escaped_value = iter.value();
|
||||
escaped_value.replace("\\", "\\\\");
|
||||
escaped_value.replace("\"", "\\\"");
|
||||
escaped_value.replace("\n", "\\\n");
|
||||
|
||||
stream << iter.key() << "=\"" << value << "\"";
|
||||
stream << iter.key() << "=\"" << escaped_value << "\"";
|
||||
|
||||
is_first = false;
|
||||
}
|
||||
|
@ -435,16 +435,16 @@ void DomainServerExporter::generateMetricsFromJson(QTextStream& stream,
|
|||
|
||||
stream << " ";
|
||||
|
||||
if (val.isBool()) {
|
||||
if (metric_value.isBool()) {
|
||||
stream << (iter.value().toBool() ? "1" : "0");
|
||||
} else if (val.isDouble()) {
|
||||
stream << val.toDouble();
|
||||
} else if (val.isString()) {
|
||||
} else if (metric_value.isDouble()) {
|
||||
stream << metric_value.toDouble();
|
||||
} else if (metric_value.isString()) {
|
||||
// Converted above
|
||||
stream << converted;
|
||||
} else {
|
||||
qCWarning(domain_server_exporter)
|
||||
<< "Can't convert metric " << orig_metric_name << "(" << metric_name << ") with value " << val;
|
||||
<< "Can't convert metric " << orig_metric_name << "(" << metric_name << ") with value " << metric_value;
|
||||
}
|
||||
|
||||
stream << "\n";
|
||||
|
|
Loading…
Reference in a new issue