mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
feat(telemetry): add toDisplayString() and use Title Case in consensus attributes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -357,7 +357,7 @@ RCLConsensus::Adaptor::onClose(
|
||||
span.setAttribute(
|
||||
telemetry::cons_span::attr::ledgerSeq,
|
||||
static_cast<int64_t>(ledger.ledger_->header().seq + 1));
|
||||
span.setAttribute(telemetry::cons_span::attr::mode, to_string(mode).c_str());
|
||||
span.setAttribute(telemetry::cons_span::attr::mode, toDisplayString(mode).c_str());
|
||||
|
||||
bool const wrongLCL = mode == ConsensusMode::wrongLedger;
|
||||
bool const proposing = mode == ConsensusMode::proposing;
|
||||
@@ -1018,8 +1018,8 @@ RCLConsensus::Adaptor::onModeChange(ConsensusMode before, ConsensusMode after)
|
||||
telemetry::TraceCategory::Consensus,
|
||||
telemetry::seg::consensus,
|
||||
telemetry::cons_span::op::modeChange);
|
||||
span.setAttribute(telemetry::cons_span::attr::modeOld, to_string(before).c_str());
|
||||
span.setAttribute(telemetry::cons_span::attr::modeNew, to_string(after).c_str());
|
||||
span.setAttribute(telemetry::cons_span::attr::modeOld, toDisplayString(before).c_str());
|
||||
span.setAttribute(telemetry::cons_span::attr::modeNew, toDisplayString(after).c_str());
|
||||
|
||||
JLOG(j_.info()) << "Consensus mode change before=" << to_string(before)
|
||||
<< ", after=" << to_string(after);
|
||||
@@ -1218,7 +1218,7 @@ RCLConsensus::Adaptor::startRoundTracing(RCLCxLedger const& prevLgr)
|
||||
|
||||
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::mode, to_string(mode_.load()).c_str());
|
||||
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));
|
||||
|
||||
|
||||
@@ -66,6 +66,26 @@ to_string(ConsensusMode m)
|
||||
}
|
||||
}
|
||||
|
||||
/// Title Case display name for telemetry attributes and dashboards.
|
||||
/// Separate from to_string() which is used in logs and must remain stable.
|
||||
inline std::string
|
||||
toDisplayString(ConsensusMode m)
|
||||
{
|
||||
switch (m)
|
||||
{
|
||||
case ConsensusMode::proposing:
|
||||
return "Proposing";
|
||||
case ConsensusMode::observing:
|
||||
return "Observing";
|
||||
case ConsensusMode::wrongLedger:
|
||||
return "Wrong Ledger";
|
||||
case ConsensusMode::switchedLedger:
|
||||
return "Switched Ledger";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/** Phases of consensus for a single ledger round.
|
||||
|
||||
@code
|
||||
|
||||
Reference in New Issue
Block a user