Respect custom service_instance_id when set in [telemetry] config

Only override serviceInstanceId with the node public key when the user
hasn't explicitly set service_instance_id in the [telemetry] section.
This allows operators to assign human-friendly names (e.g. "validator-1")
while still defaulting to the node's base58 public key.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Pratik Mankawde
2026-03-08 19:04:46 +00:00
parent 9dfa3510ff
commit aed3d4f6ab

View File

@@ -1269,10 +1269,12 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
nodeIdentity_ = getNodeIdentity(*this, cmdline);
// Now that the node identity is known, inject it into the telemetry
// resource attributes. The Telemetry object was constructed with an
// empty serviceInstanceId because nodeIdentity_ is not available in
// the ApplicationImp member initializer list.
telemetry_->setServiceInstanceId(toBase58(TokenType::NodePublic, nodeIdentity_->first));
// 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(SECTION_CLUSTER_NODES)))
{