Skip to content

Commit a190cd8

Browse files
Phase 4: Consensus tracing — round lifecycle, proposals, validations
- Instrument Adaptor::propose with consensus.proposal.send span and round sequence attribute - Instrument Adaptor::onClose with consensus.ledger_close span, ledger sequence, and consensus mode (proposing/observing/wrongLedger) - Instrument Adaptor::onAccept with consensus.accept span, proposer count, and round time attributes - Instrument Adaptor::validate with consensus.validation.send span, ledger sequence, and proposing flag Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c2ad81d commit a190cd8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/xrpld/app/consensus/RCLConsensus.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <xrpld/consensus/LedgerTiming.h>
1515
#include <xrpld/overlay/Overlay.h>
1616
#include <xrpld/overlay/predicates.h>
17+
#include <xrpld/telemetry/TracingInstrumentation.h>
1718

1819
#include <xrpl/basics/random.h>
1920
#include <xrpl/beast/core/LexicalCast.h>
@@ -173,6 +174,9 @@ RCLConsensus::Adaptor::share(RCLCxTx const& tx)
173174
void
174175
RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
175176
{
177+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.proposal.send");
178+
XRPL_TRACE_SET_ATTR("xrpl.consensus.round", static_cast<int64_t>(proposal.proposeSeq()));
179+
176180
JLOG(j_.trace()) << (proposal.isBowOut() ? "We bow out: " : "We propose: ")
177181
<< xrpl::to_string(proposal.prevLedger()) << " -> "
178182
<< xrpl::to_string(proposal.position());
@@ -275,6 +279,16 @@ RCLConsensus::Adaptor::onClose(
275279
NetClock::time_point const& closeTime,
276280
ConsensusMode mode) -> Result
277281
{
282+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.ledger_close");
283+
XRPL_TRACE_SET_ATTR(
284+
"xrpl.consensus.ledger.seq",
285+
static_cast<int64_t>(ledger.ledger_->header().seq + 1));
286+
XRPL_TRACE_SET_ATTR(
287+
"xrpl.consensus.mode",
288+
(mode == ConsensusMode::proposing
289+
? "proposing"
290+
: (mode == ConsensusMode::observing ? "observing" : "wrongLedger")));
291+
278292
bool const wrongLCL = mode == ConsensusMode::wrongLedger;
279293
bool const proposing = mode == ConsensusMode::proposing;
280294

@@ -383,6 +397,12 @@ RCLConsensus::Adaptor::onAccept(
383397
Json::Value&& consensusJson,
384398
bool const validating)
385399
{
400+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.accept");
401+
XRPL_TRACE_SET_ATTR("xrpl.consensus.proposers", static_cast<int64_t>(result.proposers));
402+
XRPL_TRACE_SET_ATTR(
403+
"xrpl.consensus.round_time_ms",
404+
static_cast<int64_t>(result.roundTime.read().count()));
405+
386406
app_.getJobQueue().addJob(
387407
jtACCEPT, "AcceptLedger", [=, this, cj = std::move(consensusJson)]() mutable {
388408
// Note that no lock is held or acquired during this job.
@@ -736,6 +756,10 @@ RCLConsensus::Adaptor::buildLCL(
736756
void
737757
RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger, RCLTxSet const& txns, bool proposing)
738758
{
759+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.validation.send");
760+
XRPL_TRACE_SET_ATTR("xrpl.consensus.ledger.seq", static_cast<int64_t>(ledger.seq()));
761+
XRPL_TRACE_SET_ATTR("xrpl.consensus.proposing", proposing);
762+
739763
using namespace std::chrono_literals;
740764

741765
auto validationTime = app_.timeKeeper().closeTime();

0 commit comments

Comments
 (0)