fix(telemetry): eliminate duplicate suppressed attribute on tx.receive span

The OTel C++ SDK's SetAttribute appends rather than overwrites on
in-flight spans. Setting suppressed=false as a default then overriding
to true resulted in both values appearing in the exported span.

Fix: remove the default-false set, place suppressed=false once after
the HashRouter check passes (non-suppressed path), and suppressed=true
remains only in the suppressed path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-06-03 17:23:59 +01:00
parent a13a858112
commit dfd67b8124

View File

@@ -1334,11 +1334,8 @@ PeerImp::handleTransaction(
span->setAttribute(tx_span::attr::txType, fmt->getName().c_str());
if (auto const version = getVersion(); !version.empty())
span->setAttribute(tx_span::attr::peerVersion, version.c_str());
// Set defaults for conditional attributes so they are always present
// on the span. The suppressed path overrides these when the
// transaction has already been seen via HashRouter.
span->setAttribute(tx_span::attr::suppressed, false);
span->setAttribute(tx_span::attr::txStatus, "new");
// Note: suppressed and txStatus are set once at each exit path
// (not as defaults here) to avoid OTel SDK attribute duplication.
// Charge strongly for attempting to relay a txn with tfInnerBatchTxn
// LCOV_EXCL_START
@@ -1403,6 +1400,7 @@ PeerImp::handleTransaction(
return;
}
span->setAttribute(tx_span::attr::suppressed, false);
JLOG(pJournal_.debug()) << "Got tx " << txID;
bool checkSignature = true;