Phase 5b: Add ledger/peer/tx spans + expand Grafana dashboards

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-02-27 18:02:08 +00:00
parent 5499cbcde4
commit be59e4940f
12 changed files with 1323 additions and 42 deletions

View File

@@ -4,6 +4,7 @@
#include <xrpld/app/ledger/OpenLedger.h>
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/CanonicalTXSet.h>
#include <xrpld/telemetry/TracingInstrumentation.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/tx/apply.h>
@@ -27,6 +28,8 @@ buildLedgerImpl(
beast::Journal j,
ApplyTxs&& applyTxs)
{
XRPL_TRACE_LEDGER(app.getTelemetry(), "ledger.build");
auto built = std::make_shared<Ledger>(*parent, closeTime);
if (built->isFlagLedger())
@@ -60,6 +63,7 @@ buildLedgerImpl(
built->header().seq < XRP_LEDGER_EARLIEST_FEES || built->read(keylet::fees()),
"xrpl::buildLedgerImpl : valid ledger fees");
built->setAccepted(closeTime, closeResolution, closeTimeCorrect);
XRPL_TRACE_SET_ATTR("xrpl.ledger.seq", static_cast<int64_t>(built->header().seq));
return built;
}
@@ -83,6 +87,8 @@ applyTransactions(
OpenView& view,
beast::Journal j)
{
XRPL_TRACE_TX(app.getTelemetry(), "tx.apply");
bool certainRetry = true;
std::size_t count = 0;
@@ -149,6 +155,8 @@ applyTransactions(
// If there are any transactions left, we must have
// tried them in at least one final pass
XRPL_ASSERT(txns.empty() || !certainRetry, "xrpl::applyTransactions : retry transactions");
XRPL_TRACE_SET_ATTR("xrpl.ledger.tx_count", static_cast<int64_t>(count));
XRPL_TRACE_SET_ATTR("xrpl.ledger.tx_failed", static_cast<int64_t>(failed.size()));
return count;
}

View File

@@ -13,6 +13,7 @@
#include <xrpld/core/TimeKeeper.h>
#include <xrpld/overlay/Overlay.h>
#include <xrpld/overlay/Peer.h>
#include <xrpld/telemetry/TracingInstrumentation.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/MathUtilities.h>
@@ -404,6 +405,9 @@ LedgerMaster::fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash)
bool
LedgerMaster::storeLedger(std::shared_ptr<Ledger const> ledger)
{
XRPL_TRACE_LEDGER(app_.getTelemetry(), "ledger.store");
XRPL_TRACE_SET_ATTR("xrpl.ledger.seq", static_cast<int64_t>(ledger->header().seq));
bool validated = ledger->header().validated;
// Returns true if we already had the ledger
return mLedgerHistory.insert(std::move(ledger), validated);
@@ -907,6 +911,10 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> const& ledger)
return;
}
XRPL_TRACE_LEDGER(app_.getTelemetry(), "ledger.validate");
XRPL_TRACE_SET_ATTR("xrpl.ledger.seq", static_cast<int64_t>(ledger->header().seq));
XRPL_TRACE_SET_ATTR("xrpl.ledger.validations", static_cast<int64_t>(tvc));
JLOG(m_journal.info()) << "Advancing accepted ledger to " << ledger->header().seq
<< " with >= " << minVal << " validations";

View File

@@ -1664,6 +1664,9 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMLedgerData> const& m)
void
PeerImp::onMessage(std::shared_ptr<protocol::TMProposeSet> const& m)
{
XRPL_TRACE_PEER(app_.getTelemetry(), "peer.proposal.receive");
XRPL_TRACE_SET_ATTR("xrpl.peer.id", static_cast<int64_t>(id_));
protocol::TMProposeSet& set = *m;
auto const sig = makeSlice(set.signature());
@@ -1690,6 +1693,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMProposeSet> const& m)
// every time a spam packet is received
PublicKey const publicKey{makeSlice(set.nodepubkey())};
auto const isTrusted = app_.validators().trusted(publicKey);
XRPL_TRACE_SET_ATTR("xrpl.peer.proposal.trusted", isTrusted);
// If the operator has specified that untrusted proposals be dropped then
// this happens here I.e. before further wasting CPU verifying the signature
@@ -2257,6 +2261,9 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidatorListCollection> const& m
void
PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
{
XRPL_TRACE_PEER(app_.getTelemetry(), "peer.validation.receive");
XRPL_TRACE_SET_ATTR("xrpl.peer.id", static_cast<int64_t>(id_));
if (m->validation().size() < 50)
{
JLOG(p_journal_.warn()) << "Validation: Too small";
@@ -2295,6 +2302,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMValidation> const& m)
// suppression for 30 seconds to avoid doing a relatively expensive
// lookup every time a spam packet is received
auto const isTrusted = app_.validators().trusted(val->getSignerPublic());
XRPL_TRACE_SET_ATTR("xrpl.peer.validation.trusted", isTrusted);
// If the operator has specified that untrusted validations be
// dropped then this happens here I.e. before further wasting CPU