diff --git a/src/tests/libxrpl/telemetry/MetricsRegistry.cpp b/src/tests/libxrpl/telemetry/MetricsRegistry.cpp index dd46824074..705995b331 100644 --- a/src/tests/libxrpl/telemetry/MetricsRegistry.cpp +++ b/src/tests/libxrpl/telemetry/MetricsRegistry.cpp @@ -19,10 +19,19 @@ #include +#include +#include #include +#include + +#include #include +#include +#include +#include + using namespace xrpl; namespace { @@ -37,8 +46,8 @@ namespace { */ class MockServiceRegistry : public ServiceRegistry { - [[noreturn]] void - throwUnimplemented() const + [[noreturn]] static void + throwUnimplemented() { throw std::logic_error("MockServiceRegistry: method not implemented"); } @@ -195,12 +204,12 @@ public: { throwUnimplemented(); } - OpenLedger& + [[nodiscard]] OpenLedger& getOpenLedger() override { throwUnimplemented(); } - OpenLedger const& + [[nodiscard]] OpenLedger const& getOpenLedger() const override { throwUnimplemented(); @@ -250,7 +259,7 @@ public: { return nullptr; } - bool + [[nodiscard]] bool isStopping() const override { return false; @@ -270,7 +279,7 @@ public: { throwUnimplemented(); } - std::optional const& + [[nodiscard]] std::optional const& getTrapTxID() const override { static std::optional const empty; @@ -301,7 +310,7 @@ protected: TEST_F(MetricsRegistryTest, disabled_construction) { // Construct with enabled=false; should be a no-op. - telemetry::MetricsRegistry registry(false, mockApp_, j_); + telemetry::MetricsRegistry const registry(false, mockApp_, j_); EXPECT_FALSE(registry.isEnabled()); } diff --git a/src/xrpld/perflog/detail/PerfLogImp.cpp b/src/xrpld/perflog/detail/PerfLogImp.cpp index 360f79fd57..a96650cad5 100644 --- a/src/xrpld/perflog/detail/PerfLogImp.cpp +++ b/src/xrpld/perflog/detail/PerfLogImp.cpp @@ -383,9 +383,13 @@ PerfLogImp::rpcEnd(std::string const& method, std::uint64_t const requestId, boo if (auto* mr = app_.getMetricsRegistry()) { if (finish) + { mr->recordRpcFinished(method, durationUs.count()); + } else + { mr->recordRpcErrored(method, durationUs.count()); + } } } diff --git a/src/xrpld/telemetry/MetricsRegistry.cpp b/src/xrpld/telemetry/MetricsRegistry.cpp index 863e9bfa46..d13486f07c 100644 --- a/src/xrpld/telemetry/MetricsRegistry.cpp +++ b/src/xrpld/telemetry/MetricsRegistry.cpp @@ -21,6 +21,12 @@ #include +#include + +#include +#include +#include + #ifdef XRPL_ENABLE_TELEMETRY #include @@ -62,8 +68,7 @@ namespace resource = opentelemetry::sdk::resource; #endif // XRPL_ENABLE_TELEMETRY -namespace xrpl { -namespace telemetry { +namespace xrpl::telemetry { MetricsRegistry::MetricsRegistry( [[maybe_unused]] bool enabled, @@ -166,6 +171,8 @@ MetricsRegistry::start(std::string const& endpoint, std::string const& instanceI JLOG(journal_.info()) << "MetricsRegistry: started successfully"; #else (void)endpoint; + (void)instanceId; + (void)enabled_; #endif // XRPL_ENABLE_TELEMETRY } @@ -202,6 +209,7 @@ MetricsRegistry::recordRpcStarted(std::string_view method) rpcStartedCounter_->Add(1, {{"method", std::string(method)}}); #else (void)method; + (void)enabled_; #endif } @@ -220,6 +228,7 @@ MetricsRegistry::recordRpcFinished(std::string_view method, std::int64_t duratio #else (void)method; (void)durationUs; + (void)enabled_; #endif } @@ -238,6 +247,7 @@ MetricsRegistry::recordRpcErrored(std::string_view method, std::int64_t duration #else (void)method; (void)durationUs; + (void)enabled_; #endif } @@ -254,6 +264,7 @@ MetricsRegistry::recordJobQueued(std::string_view jobType) jobQueuedCounter_->Add(1, {{"job_type", std::string(jobType)}}); #else (void)jobType; + (void)enabled_; #endif } @@ -272,6 +283,7 @@ MetricsRegistry::recordJobStarted(std::string_view jobType, std::int64_t queuedD #else (void)jobType; (void)queuedDurUs; + (void)enabled_; #endif } @@ -290,6 +302,7 @@ MetricsRegistry::recordJobFinished(std::string_view jobType, std::int64_t runnin #else (void)jobType; (void)runningDurUs; + (void)enabled_; #endif } @@ -1164,5 +1177,4 @@ MetricsRegistry::incrementJqTransOverflow() #endif } -} // namespace telemetry -} // namespace xrpl +} // namespace xrpl::telemetry