This is an automated email from the ASF dual-hosted git repository.
jpeach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 9bc1790 Precalculated the master per-framework metrics prefix.
9bc1790 is described below
commit 9bc1790d4885ef04ac676dd73a11064eca9ce833
Author: James Peach <[email protected]>
AuthorDate: Wed Sep 4 17:48:17 2019 -0700
Precalculated the master per-framework metrics prefix.
Rather than store a copy of the FrameworkInfo and generate the prefix
in the FrameworkMetrics each time we add metric, generate the prefix
once and store that.
Review: https://reviews.apache.org/r/71429/
---
src/master/metrics.cpp | 41 +++++++++++++++--------------------------
src/master/metrics.hpp | 2 +-
2 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/src/master/metrics.cpp b/src/master/metrics.cpp
index e3c871c..20d7231 100644
--- a/src/master/metrics.cpp
+++ b/src/master/metrics.cpp
@@ -717,24 +717,16 @@ void Metrics::transitionOperationState(
FrameworkMetrics::FrameworkMetrics(
const FrameworkInfo& _frameworkInfo,
bool _publishPerFrameworkMetrics)
- : frameworkInfo(_frameworkInfo),
+ : metricPrefix(getFrameworkMetricPrefix(_frameworkInfo)),
publishPerFrameworkMetrics(_publishPerFrameworkMetrics),
- subscribed(
- getFrameworkMetricPrefix(frameworkInfo) + "subscribed"),
- calls(
- getFrameworkMetricPrefix(frameworkInfo) + "calls"),
- events(
- getFrameworkMetricPrefix(frameworkInfo) + "events"),
- offers_sent(
- getFrameworkMetricPrefix(frameworkInfo) + "offers/sent"),
- offers_accepted(
- getFrameworkMetricPrefix(frameworkInfo) + "offers/accepted"),
- offers_declined(
- getFrameworkMetricPrefix(frameworkInfo) + "offers/declined"),
- offers_rescinded(
- getFrameworkMetricPrefix(frameworkInfo) + "offers/rescinded"),
- operations(
- getFrameworkMetricPrefix(frameworkInfo) + "operations")
+ subscribed(metricPrefix + "subscribed"),
+ calls(metricPrefix + "calls"),
+ events(metricPrefix + "events"),
+ offers_sent(metricPrefix + "offers/sent"),
+ offers_accepted(metricPrefix + "offers/accepted"),
+ offers_declined(metricPrefix + "offers/declined"),
+ offers_rescinded(metricPrefix + "offers/rescinded"),
+ operations(metricPrefix + "operations")
{
addMetric(subscribed);
addMetric(offers_sent);
@@ -758,8 +750,7 @@ FrameworkMetrics::FrameworkMetrics(
}
Counter counter = Counter(
- getFrameworkMetricPrefix(frameworkInfo) + "calls/" +
- strings::lower(descriptor->name()));
+ metricPrefix + "calls/" + strings::lower(descriptor->name()));
call_types.put(type, counter);
addMetric(counter);
@@ -781,8 +772,7 @@ FrameworkMetrics::FrameworkMetrics(
}
Counter counter = Counter(
- getFrameworkMetricPrefix(frameworkInfo) + "events/" +
- strings::lower(descriptor->name()));
+ metricPrefix + "events/" + strings::lower(descriptor->name()));
event_types.put(type, counter);
addMetric(counter);
@@ -797,14 +787,14 @@ FrameworkMetrics::FrameworkMetrics(
if (protobuf::isTerminalState(state)) {
Counter counter = Counter(
- getFrameworkMetricPrefix(frameworkInfo) + "tasks/terminal/" +
+ metricPrefix + "tasks/terminal/" +
strings::lower(descriptor->name()));
terminal_task_states.put(state, counter);
addMetric(counter);
} else {
PushGauge gauge = PushGauge(
- getFrameworkMetricPrefix(frameworkInfo) + "tasks/active/" +
+ metricPrefix + "tasks/active/" +
strings::lower(TaskState_Name(state)));
active_task_states.put(state, gauge);
@@ -827,9 +817,8 @@ FrameworkMetrics::FrameworkMetrics(
continue;
}
- Counter counter =
- Counter(getFrameworkMetricPrefix(frameworkInfo) +
- "operations/" + strings::lower(descriptor->name()));
+ Counter counter = Counter(
+ metricPrefix + "operations/" + strings::lower(descriptor->name()));
operation_types.put(type, counter);
addMetric(counter);
diff --git a/src/master/metrics.hpp b/src/master/metrics.hpp
index 04fecf2..acb421d 100644
--- a/src/master/metrics.hpp
+++ b/src/master/metrics.hpp
@@ -307,7 +307,7 @@ struct FrameworkMetrics
template <typename T> void addMetric(const T& metric);
template <typename T> void removeMetric(const T& metric);
- const FrameworkInfo frameworkInfo;
+ const std::string metricPrefix;
bool publishPerFrameworkMetrics;