mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 01:12:12 +00:00
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#include <Common/CurrentMetrics.h>
|
|
#include <Columns/ColumnString.h>
|
|
#include <Columns/ColumnsNumber.h>
|
|
#include <DataTypes/DataTypeString.h>
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
#include <DataStreams/OneBlockInputStream.h>
|
|
#include <Storages/System/StorageSystemMetrics.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
|
|
StorageSystemMetrics::StorageSystemMetrics(const std::string & name_)
|
|
: name(name_)
|
|
{
|
|
setColumns(ColumnsDescription({
|
|
{"metric", std::make_shared<DataTypeString>()},
|
|
{"value", std::make_shared<DataTypeInt64>()},
|
|
}));
|
|
}
|
|
|
|
|
|
BlockInputStreams StorageSystemMetrics::read(
|
|
const Names & column_names,
|
|
const SelectQueryInfo &,
|
|
const Context &,
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
const size_t /*max_block_size*/,
|
|
const unsigned /*num_streams*/)
|
|
{
|
|
check(column_names);
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
|
|
|
MutableColumns res_columns = getSampleBlock().cloneEmptyColumns();
|
|
|
|
for (size_t i = 0, end = CurrentMetrics::end(); i < end; ++i)
|
|
{
|
|
Int64 value = CurrentMetrics::values[i].load(std::memory_order_relaxed);
|
|
|
|
res_columns[0]->insert(String(CurrentMetrics::getDescription(CurrentMetrics::Metric(i))));
|
|
res_columns[1]->insert(value);
|
|
}
|
|
|
|
return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(getSampleBlock().cloneWithColumns(std::move(res_columns))));
|
|
}
|
|
|
|
|
|
}
|