Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,23 @@ void PrestoServer::run() {
if (folly::Singleton<velox::BaseStatsReporter>::try_get()) {
httpServer_->registerGet(
"/v1/info/metrics",
[](proxygen::HTTPMessage* /*message*/,
[](proxygen::HTTPMessage* message,
const std::vector<std::unique_ptr<folly::IOBuf>>& /*body*/,
proxygen::ResponseHandler* downstream) {
http::sendOkResponse(
downstream,
folly::Singleton<velox::BaseStatsReporter>::try_get()
->fetchMetrics());
auto acceptHeader = message->getHeaders().getSingleOrEmpty(
proxygen::HTTPHeaderCode::HTTP_HEADER_ACCEPT);
if (acceptHeader.find(http::kMimeTypeTextPlain) !=
std::string::npos) {
http::sendOkTextResponse(
downstream,
folly::Singleton<velox::BaseStatsReporter>::try_get()
->fetchMetrics());
} else {
http::sendOkResponse(
downstream,
folly::Singleton<velox::BaseStatsReporter>::try_get()
->fetchMetrics());
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ constexpr uint16_t kHttpInternalServerError = 500;

constexpr char kMimeTypeApplicationJson[] = "application/json";
constexpr char kMimeTypeApplicationThrift[] = "application/x-thrift+binary";
constexpr char kMimeTypeTextPlain[] = "text/plain";
constexpr char kShuttingDown[] = "\"SHUTTING_DOWN\"";
constexpr char kPrestoInternalBearer[] = "X-Presto-Internal-Bearer";

Expand Down
10 changes: 10 additions & 0 deletions presto-native-execution/presto_cpp/main/http/HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ void sendOkResponse(
.sendWithEOM();
}

void sendOkTextResponse(
proxygen::ResponseHandler* downstream,
const std::string& body) {
proxygen::ResponseBuilder(downstream)
.status(http::kHttpOk, "")
.header(proxygen::HTTP_HEADER_CONTENT_TYPE, http::kMimeTypeTextPlain)
.body(body)
.sendWithEOM();
}

void sendOkThriftResponse(
proxygen::ResponseHandler* downstream,
const std::string& body) {
Expand Down
4 changes: 4 additions & 0 deletions presto-native-execution/presto_cpp/main/http/HttpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ void sendOkResponse(
proxygen::ResponseHandler* downstream,
const std::string& body);

void sendOkTextResponse(
proxygen::ResponseHandler* downstream,
const std::string& body);

void sendOkThriftResponse(
proxygen::ResponseHandler* downstream,
const std::string& body);
Expand Down
Loading