1 | |
---|---|
2 | #include <Common/CurrentMetrics.h> |
3 | #include <DataTypes/DataTypeString.h> |
4 | #include <DataTypes/DataTypesNumber.h> |
5 | #include <Storages/System/StorageSystemMetrics.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | NamesAndTypesList StorageSystemMetrics::getNamesAndTypes() |
12 | { |
13 | return { |
14 | {"metric", std::make_shared<DataTypeString>()}, |
15 | {"value", std::make_shared<DataTypeInt64>()}, |
16 | {"description", std::make_shared<DataTypeString>()}, |
17 | }; |
18 | } |
19 | |
20 | void StorageSystemMetrics::fillData(MutableColumns & res_columns, const Context &, const SelectQueryInfo &) const |
21 | { |
22 | for (size_t i = 0, end = CurrentMetrics::end(); i < end; ++i) |
23 | { |
24 | Int64 value = CurrentMetrics::values[i].load(std::memory_order_relaxed); |
25 | |
26 | res_columns[0]->insert(CurrentMetrics::getName(CurrentMetrics::Metric(i))); |
27 | res_columns[1]->insert(value); |
28 | res_columns[2]->insert(CurrentMetrics::getDocumentation(CurrentMetrics::Metric(i))); |
29 | } |
30 | } |
31 | |
32 | } |
33 |