diff --git a/trpc/admin/prometheus_handler.cc b/trpc/admin/prometheus_handler.cc index 1e6c4d90..252215fe 100644 --- a/trpc/admin/prometheus_handler.cc +++ b/trpc/admin/prometheus_handler.cc @@ -79,6 +79,8 @@ bool PrometheusHandler::CheckBasicAuth(std::string token) { void PrometheusHandler::CommandHandle(http::HttpRequestPtr req, rapidjson::Value& result, rapidjson::Document::AllocatorType& alloc) { + static std::unique_ptr<::prometheus::Serializer> serializer = std::make_unique<::prometheus::TextSerializer>(); + std::string prometheus_str = serializer->Serialize(trpc::prometheus::Collect()); std::string token = req->GetHeader("authorization");