mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
fix(telemetry): address clang-tidy CI failures on phase9
- MetricsRegistry.cpp: concatenate nested namespaces, add missing direct includes (Journal.h, string, string_view, cstdint), suppress readability-convert-member-functions-to-static in #else stubs by referencing enabled_ member, void unused instanceId parameter. - MetricsRegistry test: add missing direct includes (Log.h, Journal.h, uint256.h, io_context.hpp, optional, stdexcept, string), make throwUnimplemented() static, add [[nodiscard]] to getOpenLedger/ isStopping/getTrapTxID overrides, make const-eligible registry const. - PerfLogImp.cpp: add braces around if/else body per readability-braces-around-statements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,10 +19,19 @@
|
||||
|
||||
#include <xrpld/telemetry/MetricsRegistry.h>
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
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<uint256> const&
|
||||
[[nodiscard]] std::optional<uint256> const&
|
||||
getTrapTxID() const override
|
||||
{
|
||||
static std::optional<uint256> 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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
|
||||
#include <xrpld/telemetry/MetricsRegistry.h>
|
||||
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#ifdef XRPL_ENABLE_TELEMETRY
|
||||
|
||||
#include <xrpld/app/ledger/AcceptedLedger.h>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user