mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Use Title Case for consensus mode names in telemetry attributes
Add toDisplayString(ConsensusMode) helper that returns Title Case names (Proposing, Observing, Wrong Ledger, Switched Ledger) for use in OTel span attributes and Grafana dashboards. The existing to_string() is preserved unchanged for log output stability. Updated call sites: - RCLConsensus.cpp: onClose, onModeChange, startRoundInternal - TracingMacros.cpp: test attribute value Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,7 @@ TEST(TracingMacros, macros_with_null_telemetry)
|
||||
}
|
||||
{
|
||||
XRPL_TRACE_CONSENSUS(*tel, "consensus.test");
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode", "proposing");
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode", "Proposing");
|
||||
}
|
||||
{
|
||||
XRPL_TRACE_PEER(*tel, "peer.test");
|
||||
|
||||
@@ -341,7 +341,7 @@ RCLConsensus::Adaptor::onClose(
|
||||
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.ledger_close");
|
||||
XRPL_TRACE_SET_ATTR(
|
||||
"xrpl.consensus.ledger.seq", static_cast<int64_t>(ledger.ledger_->header().seq + 1));
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode", to_string(mode).c_str());
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode", toDisplayString(mode).c_str());
|
||||
|
||||
bool const wrongLCL = mode == ConsensusMode::wrongLedger;
|
||||
bool const proposing = mode == ConsensusMode::proposing;
|
||||
@@ -939,8 +939,8 @@ RCLConsensus::Adaptor::onModeChange(ConsensusMode before, ConsensusMode after)
|
||||
// trace backend. Each transition (e.g. observing -> proposing) appears
|
||||
// as a child of the current consensus.round span.
|
||||
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.mode_change");
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode.old", to_string(before).c_str());
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode.new", to_string(after).c_str());
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode.old", toDisplayString(before).c_str());
|
||||
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode.new", toDisplayString(after).c_str());
|
||||
|
||||
JLOG(j_.info()) << "Consensus mode change before=" << to_string(before)
|
||||
<< ", after=" << to_string(after);
|
||||
@@ -1174,7 +1174,7 @@ RCLConsensus::Adaptor::startRoundTracing(RCLCxLedger const& prevLgr)
|
||||
// Set standard attributes on the round span.
|
||||
roundSpan_->setAttribute("xrpl.consensus.ledger_id", to_string(prevLgr.id()).c_str());
|
||||
roundSpan_->setAttribute("xrpl.consensus.ledger.seq", static_cast<int64_t>(prevLgr.seq() + 1));
|
||||
roundSpan_->setAttribute("xrpl.consensus.mode", to_string(mode_.load()).c_str());
|
||||
roundSpan_->setAttribute("xrpl.consensus.mode", toDisplayString(mode_.load()).c_str());
|
||||
roundSpan_->setAttribute("xrpl.consensus.trace_strategy", strategy.c_str());
|
||||
roundSpan_->setAttribute("xrpl.consensus.round_id", 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