17 #include <boost/algorithm/string.hpp>
18 #include <boost/foreach.hpp>
19 #include <gutil/strings/substitute.h>
24 using boost::algorithm::to_lower;
25 using namespace impala;
26 using namespace strings;
35 #ifndef ADDRESS_SANITIZER
37 "tcmalloc.bytes-in-use",
"generic.current_allocated_bytes"));
40 "tcmalloc.total-bytes-reserved",
"generic.heap_size"));
43 "tcmalloc.pageheap-free-bytes",
"tcmalloc.pageheap_free_bytes"));
46 "tcmalloc.pageheap-unmapped-bytes",
"tcmalloc.pageheap_unmapped_bytes"));
52 if (register_jvm_metrics) {
66 DCHECK(metrics != NULL);
67 TGetJvmMetricsRequest request;
68 request.get_all =
true;
69 TGetJvmMetricsResponse response;
71 BOOST_FOREACH(
const TJvmMemoryPool& usage, response.memory_pools) {
72 string name = usage.name;
74 replace(name.begin(), name.end(),
' ',
'-');
76 new JvmMetric(Substitute(
"jvm.$0.max-usage-bytes", name), usage.name,
MAX));
78 new JvmMetric(Substitute(
"jvm.$0.current-usage-bytes", name),
81 new JvmMetric(Substitute(
"jvm.$0.committed-usage-bytes", name), usage.name,
84 new JvmMetric(Substitute(
"jvm.$0.init-usage-bytes", name), usage.name,
INIT));
86 new JvmMetric(Substitute(
"jvm.$0.peak-max-usage-bytes", name), usage.name,
89 new JvmMetric(Substitute(
"jvm.$0.peak-current-usage-bytes", name),
92 new JvmMetric(Substitute(
"jvm.$0.peak-committed-usage-bytes", name), usage.name,
95 new JvmMetric(Substitute(
"jvm.$0.peak-init-usage-bytes", name), usage.name,
103 TGetJvmMetricsRequest request;
104 request.get_all =
false;
106 TGetJvmMetricsResponse response;
108 if (response.memory_pools.size() != 1)
return;
109 TJvmMemoryPool&
pool = response.memory_pools[0];
112 case MAX: value_ = pool.max;
114 case INIT: value_ = pool.init;
116 case CURRENT: value_ = pool.used;
120 case PEAK_MAX: value_ = pool.peak_max;
128 default: DCHECK(
false) <<
"Unknown JvmMetricType: " <<
metric_type_;
JvmMetric(const std::string &key, const std::string &mempool_name, JvmMetricType type)
Private constructor to ensure only InitMetrics() can create JvmMetrics.
#define RETURN_IF_ERROR(stmt)
some generally useful macros
M * RegisterMetric(M *metric)
MetricGroup * GetChildGroup(const std::string &name)
Creates or returns an already existing child metric group.
Status RegisterMemoryMetrics(MetricGroup *metrics, bool register_jvm_metrics)
MetricGroups may be organised hierarchically as a tree.
static TcmallocMetric * PAGEHEAP_UNMAPPED_BYTES
JvmMetricType metric_type_
static PhysicalBytesMetric * PHYSICAL_BYTES_RESERVED
static Status InitMetrics(MetricGroup *metrics)
static TcmallocMetric * PAGEHEAP_FREE_BYTES
virtual void CalculateValue()
std::string mempool_name_
The name of the memory pool, defined by the Jvm.
Specialised metric which exposes numeric properties from tcmalloc.
static TcmallocMetric * TOTAL_BYTES_RESERVED
static Status GetJvmMetrics(const TGetJvmMetricsRequest &request, TGetJvmMetricsResponse *result)
static TcmallocMetric * BYTES_IN_USE
Number of bytes allocated by tcmalloc, currently used by the application.
JvmMetricType
Each names one of the fields in TJvmMemoryPool.