diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 8031d9ade..02920617c 100755 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -2560,6 +2560,9 @@ True + + True + @@ -2568,6 +2571,8 @@ + + diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 6726fc089..532cc2966 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -3654,6 +3654,9 @@ ripple\nodestore\impl + + ripple\nodestore\impl + ripple\nodestore\impl @@ -3666,6 +3669,9 @@ ripple\nodestore + + ripple\nodestore + ripple\nodestore diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index bf2f03b1a..54ef26637 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -311,9 +311,8 @@ public: // VFALCO NOTE LocalCredentials starts the deprecated UNL service , m_deprecatedUNL (make_UniqueNodeList (*m_jobQueue)) - , serverHandler_ (make_ServerHandler (*m_networkOPs, - get_io_service(), *m_jobQueue, *m_networkOPs, - *m_resourceManager)) + , serverHandler_ (make_ServerHandler (*m_networkOPs, get_io_service (), + *m_jobQueue, *m_networkOPs, *m_resourceManager, *m_collectorManager)) , m_sntpClient (SNTPClient::New (*this)) @@ -743,7 +742,8 @@ public: { if (! port.websockets()) continue; - auto door = make_WSDoor(port, *m_resourceManager, getOPs()); + auto door (make_WSDoor (port, *m_resourceManager, getOPs (), + *m_collectorManager)); if (door == nullptr) { m_journal.fatal << "Could not create Websocket for [" << diff --git a/src/ripple/app/websocket/WSConnection.cpp b/src/ripple/app/websocket/WSConnection.cpp index c0041d09b..bf9447fcc 100644 --- a/src/ripple/app/websocket/WSConnection.cpp +++ b/src/ripple/app/websocket/WSConnection.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include namespace ripple { @@ -177,6 +176,7 @@ Json::Value WSConnection::invokeCommand (Json::Value& jvRequest) jvRequest, loadType, m_netOPs, role, std::dynamic_pointer_cast (this->shared_from_this ())}; RPC::doCommand (context, jvResult[jss::result]); + recordMetrics (context); } getConsumer().charge (loadType); diff --git a/src/ripple/app/websocket/WSConnection.h b/src/ripple/app/websocket/WSConnection.h index 98c2ca0d8..96e46b3aa 100644 --- a/src/ripple/app/websocket/WSConnection.h +++ b/src/ripple/app/websocket/WSConnection.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,8 @@ protected: virtual void preDestroy () = 0; virtual void disconnect () = 0; + + virtual void recordMetrics (RPC::Context const&) const = 0; public: void onPong (std::string const&); @@ -142,6 +145,11 @@ public: // Just discards the reference } + void recordMetrics (RPC::Context const& context) const override + { + m_serverHandler.recordMetrics (context); + } + // Implement overridden functions from base class: void send (Json::Value const& jvObj, bool broadcast) { diff --git a/src/ripple/app/websocket/WSDoor.cpp b/src/ripple/app/websocket/WSDoor.cpp index 15246f43d..a21037cca 100644 --- a/src/ripple/app/websocket/WSDoor.cpp +++ b/src/ripple/app/websocket/WSDoor.cpp @@ -57,15 +57,17 @@ private: InfoSub::Source& m_source; LockType m_endpointLock; std::shared_ptr m_endpoint; + CollectorManager& collectorManager_; public: WSDoorImp (HTTP::Port const& port, Resource::Manager& resourceManager, - InfoSub::Source& source) + InfoSub::Source& source, CollectorManager& cm) : WSDoor (source) , Thread ("websocket") , port_(std::make_shared(port)) , m_resourceManager (resourceManager) , m_source (source) + , collectorManager_ (cm) { startThread (); } @@ -85,7 +87,7 @@ private: websocketpp_02::server_autotls::handler::ptr handler ( new WSServerHandler ( - port_, m_resourceManager, m_source)); + port_, m_resourceManager, m_source, collectorManager_)); { ScopedLockType lock (m_endpointLock); @@ -162,13 +164,13 @@ WSDoor::WSDoor (Stoppable& parent) std::unique_ptr make_WSDoor (HTTP::Port const& port, Resource::Manager& resourceManager, - InfoSub::Source& source) + InfoSub::Source& source, CollectorManager& cm) { std::unique_ptr door; try { - door = std::make_unique (port, resourceManager, source); + door = std::make_unique (port, resourceManager, source, cm); } catch (...) { diff --git a/src/ripple/app/websocket/WSDoor.h b/src/ripple/app/websocket/WSDoor.h index fc2c41214..d93810acf 100644 --- a/src/ripple/app/websocket/WSDoor.h +++ b/src/ripple/app/websocket/WSDoor.h @@ -42,7 +42,7 @@ public: std::unique_ptr make_WSDoor (HTTP::Port const& port, Resource::Manager& resourceManager, - InfoSub::Source& source); + InfoSub::Source& source, CollectorManager& cm); } diff --git a/src/ripple/app/websocket/WSServerHandler.h b/src/ripple/app/websocket/WSServerHandler.h index c5185d7c4..2e4df6f2e 100644 --- a/src/ripple/app/websocket/WSServerHandler.h +++ b/src/ripple/app/websocket/WSServerHandler.h @@ -69,6 +69,10 @@ private: std::shared_ptr port_; Resource::Manager& m_resourceManager; InfoSub::Source& m_source; + beast::insight::Counter rpc_requests_; + beast::insight::Event rpc_io_; + beast::insight::Event rpc_size_; + beast::insight::Event rpc_time_; protected: // VFALCO TODO Make this private. @@ -82,11 +86,17 @@ protected: public: WSServerHandler (std::shared_ptr const& port, - Resource::Manager& resourceManager, InfoSub::Source& source) + Resource::Manager& resourceManager, InfoSub::Source& source, + CollectorManager& cm) : port_(port) , m_resourceManager (resourceManager) , m_source (source) { + auto const& group (cm.group ("rpc")); + rpc_requests_ = group->make_counter ("requests"); + rpc_io_ = group->make_event ("io"); + rpc_size_ = group->make_event ("size"); + rpc_time_ = group->make_event ("time"); } WSServerHandler(WSServerHandler const&) = delete; @@ -426,8 +436,17 @@ public: if (jCmd.isString()) job.rename (std::string ("WSClient::") + jCmd.asString()); } - - send (cpClient, conn->invokeCommand (jvRequest), false); + + auto const start (std::chrono::high_resolution_clock::now ()); + Json::Value const jvObj (conn->invokeCommand (jvRequest)); + std::string const buffer (to_string (jvObj)); + rpc_time_.notify (static_cast ( + std::chrono::duration_cast ( + std::chrono::high_resolution_clock::now () - start))); + ++rpc_requests_; + rpc_size_.notify (static_cast + (buffer.size ())); + send (cpClient, buffer, false); } return true; @@ -470,6 +489,12 @@ public: " TestThis page shows http(s) connectivity is working.
This page shows http(s) connectivity is working.