Merge branch 'pratik/otel-phase1c-rpc-integration' into pratik/otel-phase2-rpc-tracing

This commit is contained in:
Pratik Mankawde
2026-07-30 19:57:42 +01:00

View File

@@ -1141,6 +1141,22 @@ private:
void
startGenesisLedger();
/**
* Start the tracing pipeline.
*
* Called once from setup(), as soon as the node identity is known.
* Starting here rather than in start() means spans emitted during the
* rest of setup() are recorded: SpanGuard drops a span whenever the
* global Telemetry instance is not yet live, and the first consensus
* round runs inside setup().
*
* @pre nodeIdentity_ is populated, so setServiceInstanceId() has
* already supplied the service.instance.id resource attribute
* (the Telemetry resource is fixed once start() builds it).
*/
void
startTelemetry();
std::shared_ptr<Ledger>
getLastFullLedger();
@@ -1227,6 +1243,27 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
return false;
}
nodeIdentity_ = getNodeIdentity(*this, cmdline);
// Now that the node identity is known, inject it into the telemetry
// resource attributes — but only if the user didn't already set a
// custom service_instance_id in [telemetry]. The Telemetry object
// was constructed with an empty serviceInstanceId because
// nodeIdentity_ is not available in the member initializer list.
if (!config_->section("telemetry").exists("service_instance_id"))
telemetry_->setServiceInstanceId(toBase58(TokenType::NodePublic, nodeIdentity_->first));
// Start telemetry here, not in start(). Spans are emitted during the rest
// of setup() — the first consensus round in beginConsensus() below — and
// are dropped unless the global Telemetry instance is already live.
//
// The position is bounded on both sides:
// - After initRelationalDatabase(): the wallet DB must exist for the node
// identity above, and a DB failure aborts setup(), so starting earlier
// would export a partial trace stream for a run that never comes up.
// - Before beginConsensus(): that call emits the first consensus spans.
startTelemetry();
if (validatorKeys_.keys)
setMaxDisallowedLedger();
@@ -1314,16 +1351,6 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
orderBookDB_->setup(getLedgerMaster().getCurrentLedger());
nodeIdentity_ = getNodeIdentity(*this, cmdline);
// Now that the node identity is known, inject it into the telemetry
// resource attributes — but only if the user didn't already set a
// custom service_instance_id in [telemetry]. The Telemetry object
// was constructed with an empty serviceInstanceId because
// nodeIdentity_ is not available in the member initializer list.
if (!config_->section("telemetry").exists("service_instance_id"))
telemetry_->setServiceInstanceId(toBase58(TokenType::NodePublic, nodeIdentity_->first));
if (!cluster_->load(config().section(Sections::kClusterNodes)))
{
JLOG(journal_.fatal()) << "Invalid entry in cluster configuration.";
@@ -1536,6 +1563,11 @@ ApplicationImp::start(bool withTimers)
ledgerCleaner_->start();
perfLog_->start();
}
void
ApplicationImp::startTelemetry()
{
telemetry_->start();
}