MCPcopy Create free account
hub / github.com/apache/impala / ToPrometheus

Method ToPrometheus

be/src/util/metrics.cc:86–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84
85template <typename T, TMetricKind::type metric_kind_t>
86TMetricKind::type ScalarMetric<T, metric_kind_t>::ToPrometheus(
87 string name, stringstream* val, stringstream* metric_kind) {
88 string metric_type = PrintValue(kind());
89 // prometheus doesn't support 'property', so ignore it
90 if (!metric_type.compare("property")) {
91 return TMetricKind::PROPERTY;
92 }
93
94 if (IsUnitTimeBased(unit())) {
95 // check if unit its 'TIME_MS','TIME_US' or 'TIME_NS' and convert it to seconds,
96 // this is because prometheus only supports time format in seconds
97 *val << ConvertToPrometheusSecs(GetValue(), unit());
98 } else {
99 *val << GetValue();
100 }
101
102 // convert metric type to lower case, that's what prometheus expects
103 std::transform(metric_type.begin(), metric_type.end(), metric_type.begin(), ::tolower);
104
105 *metric_kind << "# TYPE " << name << " " << metric_type;
106 return kind();
107}
108
109template <typename T, TMetricKind::type metric_kind_t>
110string ScalarMetric<T, metric_kind_t>::ToHumanReadable() {

Callers 1

TEST_FFunction · 0.45

Calls 7

PrintValueFunction · 0.85
ConvertToPrometheusSecsFunction · 0.85
compareMethod · 0.65
transformFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by 1

TEST_FFunction · 0.36