mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
43 lines
990 B
C++
43 lines
990 B
C++
#include "PrometheusRequestHandler.h"
|
|
|
|
#include <IO/HTTPCommon.h>
|
|
|
|
#include <Common/Exception.h>
|
|
|
|
#include <Poco/Net/HTTPServerRequest.h>
|
|
#include <Poco/Net/HTTPServerResponse.h>
|
|
|
|
#include <Common/ProfileEvents.h>
|
|
#include <Common/CurrentMetrics.h>
|
|
|
|
#include <IO/WriteBufferFromHTTPServerResponse.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
void PrometheusRequestHandler::handleRequest(
|
|
Poco::Net::HTTPServerRequest & request,
|
|
Poco::Net::HTTPServerResponse & response)
|
|
{
|
|
try
|
|
{
|
|
const auto & config = server.config();
|
|
unsigned keep_alive_timeout = config.getUInt("keep_alive_timeout", 10);
|
|
|
|
setResponseDefaultHeaders(response, keep_alive_timeout);
|
|
|
|
response.setContentType("text/plain; version=0.0.4; charset=UTF-8");
|
|
|
|
auto wb = WriteBufferFromHTTPServerResponse(request, response, keep_alive_timeout);
|
|
metrics_writer.write(wb);
|
|
wb.finalize();
|
|
}
|
|
catch (...)
|
|
{
|
|
tryLogCurrentException("PrometheusRequestHandler");
|
|
}
|
|
}
|
|
|
|
}
|