aboutsummaryrefslogtreecommitdiff
path: root/src/common/Metric/Metric.cpp
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-07-28 12:27:54 +0000
committerGitHub <noreply@github.com>2020-07-28 14:27:54 +0200
commit8a2c79c850199a73fd431d04f83d6aa89733060d (patch)
tree7f29acac68d13b9ec9239b9fe9536b6f1e0bda9c /src/common/Metric/Metric.cpp
parent8642aaaf9268364454b409db7eb62f31210e6d6c (diff)
Core/Metric: Log detailed metrics about each opcode handler (#25153)
* Core/Metric: Log detailed metrics about each opcode handler * Add new panel to Performance profiling dashboard and use fill(0) instead of fill(none) * Add new settings Metric.Threshold.* to be able to specify the minimum threshold for the specified metrics * Update dashboard * Change thresholds to be required to send the metrics. A TC_METRIC_DETAILED_TIMER metric with an expected threshold not configured will be ignored * Use typedef Milliseconds * Refresh realms on load
Diffstat (limited to 'src/common/Metric/Metric.cpp')
-rw-r--r--src/common/Metric/Metric.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index d22839e8a79..b5762dbd8e2 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -69,6 +69,15 @@ void Metric::LoadFromConfigs()
_overallStatusTimerInterval = 1;
}
+ _thresholds.clear();
+ std::vector<std::string> thresholdSettings = sConfigMgr->GetKeysByString("Metric.Threshold.");
+ for (std::string const& thresholdSetting : thresholdSettings)
+ {
+ int thresholdValue = sConfigMgr->GetIntDefault(thresholdSetting, 0);
+ std::string thresholdName = thresholdSetting.substr(strlen("Metric.Threshold."));
+ _thresholds[thresholdName] = thresholdValue;
+ }
+
// Schedule a send at this point only if the config changed from Disabled to Enabled.
// Cancel any scheduled operation if the config changed from Enabled to Disabled.
if (_enabled && !previousValue)
@@ -106,6 +115,14 @@ void Metric::Update()
}
}
+bool Metric::ShouldLog(std::string const& category, int64 value) const
+{
+ auto threshold = _thresholds.find(category);
+ if (threshold == _thresholds.end())
+ return false;
+ return value >= threshold->second;
+}
+
void Metric::LogEvent(std::string const& category, std::string const& title, std::string const& description)
{
using namespace std::chrono;
@@ -281,7 +298,7 @@ std::string Metric::FormatInfluxDBTagValue(std::string const& value)
std::string Metric::FormatInfluxDBValue(std::chrono::nanoseconds value)
{
- return FormatInfluxDBValue(std::chrono::duration_cast<std::chrono::milliseconds>(value).count());
+ return FormatInfluxDBValue(std::chrono::duration_cast<Milliseconds>(value).count());
}
Metric::Metric()