mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
fix(telemetry): address clang-tidy errors on phase4 consensus tracing files
- Add [[nodiscard]] to getConsensusTraceStrategy, getYays, getNays - Add missing <string>, SpanGuard.h, SpanNames.h includes - Fix widening cast placement (cast before arithmetic, not after) - Replace nested ternary with lambda for const dir variable - Add braces to if/else-if chains in Consensus.h - Concatenate nested namespaces in ConsensusSpanNames.h Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -252,7 +252,7 @@ public:
|
||||
shouldTraceLedger() const = 0;
|
||||
|
||||
/** @return The configured consensus trace correlation strategy. */
|
||||
virtual std::string const&
|
||||
[[nodiscard]] virtual std::string const&
|
||||
getConsensusTraceStrategy() const = 0;
|
||||
|
||||
#ifdef XRPL_ENABLE_TELEMETRY
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl::telemetry {
|
||||
@@ -87,7 +88,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string const&
|
||||
[[nodiscard]] std::string const&
|
||||
getConsensusTraceStrategy() const override
|
||||
{
|
||||
return setup_.consensusTraceStrategy;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using namespace xrpl;
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
#include <xrpl/shamap/SHAMapItem.h>
|
||||
#include <xrpl/shamap/SHAMapMissingNode.h>
|
||||
#include <xrpl/shamap/SHAMapTreeNode.h>
|
||||
#include <xrpl/telemetry/SpanGuard.h>
|
||||
#include <xrpl/telemetry/SpanNames.h>
|
||||
#include <xrpl/telemetry/Telemetry.h>
|
||||
#include <xrpl/telemetry/TraceContextPropagator.h>
|
||||
|
||||
@@ -357,7 +359,7 @@ RCLConsensus::Adaptor::onClose(
|
||||
telemetry::cons_span::op::ledgerClose);
|
||||
span.setAttribute(
|
||||
telemetry::cons_span::attr::ledgerSeq,
|
||||
static_cast<int64_t>(ledger.ledger_->header().seq + 1));
|
||||
static_cast<int64_t>(ledger.ledger_->header().seq) + 1);
|
||||
span.setAttribute(telemetry::cons_span::attr::mode, toDisplayString(mode).c_str());
|
||||
|
||||
bool const wrongLCL = mode == ConsensusMode::wrongLedger;
|
||||
@@ -556,7 +558,7 @@ RCLConsensus::Adaptor::doAccept(
|
||||
? acceptSpan->childSpan(telemetry::cons_span::acceptApply)
|
||||
: telemetry::SpanGuard::childSpan(telemetry::cons_span::acceptApply, roundSpanContext_);
|
||||
doAcceptSpan.setAttribute(
|
||||
telemetry::cons_span::attr::ledgerSeq, static_cast<int64_t>(prevLedger.seq() + 1));
|
||||
telemetry::cons_span::attr::ledgerSeq, static_cast<int64_t>(prevLedger.seq()) + 1);
|
||||
doAcceptSpan.setAttribute(
|
||||
telemetry::cons_span::attr::closeTime,
|
||||
static_cast<int64_t>(consensusCloseTime.time_since_epoch().count()));
|
||||
@@ -582,9 +584,17 @@ RCLConsensus::Adaptor::doAccept(
|
||||
static_cast<int64_t>(rawCloseTimes.peers.size()));
|
||||
{
|
||||
auto const prevRes = prevLedger.closeTimeResolution();
|
||||
std::string dir = (closeResolution > prevRes) ? "increased"
|
||||
: (closeResolution < prevRes) ? "decreased"
|
||||
: "unchanged";
|
||||
auto const dir = [&]() -> std::string {
|
||||
if (closeResolution > prevRes)
|
||||
{
|
||||
return "increased";
|
||||
}
|
||||
if (closeResolution < prevRes)
|
||||
{
|
||||
return "decreased";
|
||||
}
|
||||
return "unchanged";
|
||||
}();
|
||||
doAcceptSpan.setAttribute(telemetry::cons_span::attr::resolutionDirection, std::move(dir));
|
||||
}
|
||||
|
||||
@@ -1218,10 +1228,10 @@ RCLConsensus::Adaptor::startRoundTracing(RCLCxLedger const& prevLgr)
|
||||
return;
|
||||
|
||||
roundSpan_->setAttribute(cons_span::attr::ledgerId, to_string(prevLgr.id()).c_str());
|
||||
roundSpan_->setAttribute(cons_span::attr::ledgerSeq, static_cast<int64_t>(prevLgr.seq() + 1));
|
||||
roundSpan_->setAttribute(cons_span::attr::ledgerSeq, static_cast<int64_t>(prevLgr.seq()) + 1);
|
||||
roundSpan_->setAttribute(cons_span::attr::mode, toDisplayString(mode_.load()).c_str());
|
||||
roundSpan_->setAttribute(cons_span::attr::traceStrategy, strategy.c_str());
|
||||
roundSpan_->setAttribute(cons_span::attr::roundId, static_cast<int64_t>(prevLgr.seq() + 1));
|
||||
roundSpan_->setAttribute(cons_span::attr::roundId, static_cast<int64_t>(prevLgr.seq()) + 1);
|
||||
|
||||
roundSpanContext_ = roundSpan_->captureContext();
|
||||
}
|
||||
|
||||
@@ -1801,11 +1801,17 @@ Consensus<Adaptor>::haveConsensus(std::unique_ptr<std::stringstream> const& clog
|
||||
|
||||
char const* stateStr = "no";
|
||||
if (result_->state == ConsensusState::Yes)
|
||||
{
|
||||
stateStr = "yes";
|
||||
}
|
||||
else if (result_->state == ConsensusState::MovedOn)
|
||||
{
|
||||
stateStr = "moved_on";
|
||||
}
|
||||
else if (result_->state == ConsensusState::Expired)
|
||||
{
|
||||
stateStr = "expired";
|
||||
}
|
||||
span.setAttribute(cons_span::attr::result, stateStr);
|
||||
|
||||
CLOG(clog) << "Consensus has been reached. ";
|
||||
|
||||
@@ -78,9 +78,7 @@
|
||||
|
||||
#include <xrpl/telemetry/SpanNames.h>
|
||||
|
||||
namespace xrpl {
|
||||
namespace telemetry {
|
||||
namespace cons_span {
|
||||
namespace xrpl::telemetry::cons_span {
|
||||
|
||||
// ===== Span name segments ====================================================
|
||||
|
||||
@@ -240,6 +238,4 @@ inline constexpr auto decreased = makeStr("decreased");
|
||||
inline constexpr auto unchanged = makeStr("unchanged");
|
||||
} // namespace val
|
||||
|
||||
} // namespace cons_span
|
||||
} // namespace telemetry
|
||||
} // namespace xrpl
|
||||
} // namespace xrpl::telemetry::cons_span
|
||||
|
||||
@@ -177,14 +177,14 @@ public:
|
||||
getJson() const;
|
||||
|
||||
//! Number of peers voting yes.
|
||||
int
|
||||
[[nodiscard]] int
|
||||
getYays() const
|
||||
{
|
||||
return yays_;
|
||||
}
|
||||
|
||||
//! Number of peers voting no.
|
||||
int
|
||||
[[nodiscard]] int
|
||||
getNays() const
|
||||
{
|
||||
return nays_;
|
||||
|
||||
Reference in New Issue
Block a user