[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server
Kirill Bobyrev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 10 00:08:59 PST 2021
kbobyrev updated this revision to Diff 329553.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.
Enabled server reflection in https://github.com/llvm/llvm-project/commit/8080ea4c4b8c456c72c617587cc32f174b3105c1
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98246/new/
https://reviews.llvm.org/D98246
Files:
clang-tools-extra/clangd/index/remote/Service.proto
clang-tools-extra/clangd/index/remote/server/Server.cpp
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -91,7 +91,7 @@
class RemoteIndexServer final : public v1::SymbolIndex::Service {
public:
RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
- : Index(Index) {
+ : Index(Index), ServiceStartTime(std::chrono::system_clock::now()) {
llvm::SmallString<256> NativePath = IndexRoot;
llvm::sys::path::native(NativePath);
ProtobufMarshaller = std::unique_ptr<Marshaller>(new Marshaller(
@@ -280,8 +280,23 @@
Millis);
}
+ grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+ const google::protobuf::Empty *Request,
+ v1::MonitoringInfoReply *Reply) override {
+ auto Uptime = std::chrono::duration_cast<std::chrono::minutes>(
+ std::chrono::system_clock::now() - ServiceStartTime)
+ .count();
+ Reply->set_info(llvm::formatv(
+ "Service started at {0:%Y-%m-%d %H:%M:%S}. Uptime: {1} h {2} m.",
+ ServiceStartTime, Uptime / 60, Uptime % 60));
+ logRequest(*Request);
+ logResponse(*Reply);
+ return grpc::Status::OK;
+ }
+
std::unique_ptr<Marshaller> ProtobufMarshaller;
clangd::SymbolIndex &Index;
+ llvm::sys::TimePoint<> ServiceStartTime;
};
// Detect changes in \p IndexPath file and load new versions of the index
Index: clang-tools-extra/clangd/index/remote/Service.proto
===================================================================
--- clang-tools-extra/clangd/index/remote/Service.proto
+++ clang-tools-extra/clangd/index/remote/Service.proto
@@ -10,8 +10,11 @@
package clang.clangd.remote.v1;
+import "google/protobuf/empty.proto";
import "Index.proto";
+message MonitoringInfoReply { optional string info = 1; }
+
// Semantics of SymbolIndex match clangd::SymbolIndex with all required
// structures corresponding to their clangd::* counterparts.
service SymbolIndex {
@@ -22,5 +25,7 @@
rpc Refs(RefsRequest) returns (stream RefsReply) {}
rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
+
+ rpc MonitoringInfo(google.protobuf.Empty) returns (MonitoringInfoReply) {}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98246.329553.patch
Type: text/x-patch
Size: 2386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210310/3058d2b0/attachment.bin>
More information about the cfe-commits
mailing list