[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
Tue Mar 9 03:26:47 PST 2021
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98246
Files:
clang-tools-extra/clangd/index/remote/Client.cpp
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
@@ -90,7 +90,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(
@@ -279,8 +279,20 @@
Millis);
}
+ grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+ const google::protobuf::Empty *Request,
+ v1::MonitoringInfoReply *Reply) override {
+ Reply->set_info(
+ llvm::formatv("Service started at {0}. Uptime: {1}", ServiceStartTime,
+ ServiceStartTime - std::chrono::system_clock::now()));
+ 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) {}
}
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -17,6 +17,7 @@
#include "clang/Basic/Version.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
#include "llvm/Support/Error.h"
#include <atomic>
@@ -70,8 +71,7 @@
SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
grpc::ClientContext Context;
Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
- std::chrono::system_clock::time_point StartTime =
- std::chrono::system_clock::now();
+ llvm::sys::TimePoint<> StartTime = std::chrono::system_clock::now();
auto Deadline = StartTime + DeadlineWaitingTime;
Context.set_deadline(Deadline);
auto Reader = (Stub.get()->*RPCCall)(&Context, RPCRequest);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98246.329278.patch
Type: text/x-patch
Size: 3182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210309/5cc14691/attachment-0001.bin>
More information about the cfe-commits
mailing list