Repository navigation
feat(metrics): extend node_info and add node status gauges #7049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a21b2a7
a9cc0ab
9bd4f6b
53f4e39
cd2ec20
c526e68
2cb285f
a0fa17f
65159f7
c992dda
98719c6
97eeaeb
04271d5
16f15a2
0457171
541306a
82c00dc
385dc89
f2e109d
3f55a94
4f42f07
fa332d3
345d81a
795eb43
8b53bbf
26a7004
efd3062
c1a58aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,9 @@ | |
| import org.springframework.stereotype.Component; | ||
| import org.tron.common.crypto.SignUtils; | ||
| import org.tron.common.parameter.CommonParameter; | ||
| import org.tron.common.prometheus.Metrics; | ||
| import org.tron.common.prometheus.SRMetrics; | ||
| import org.tron.common.utils.StringUtil; | ||
| import org.tron.consensus.Consensus; | ||
| import org.tron.consensus.base.Param; | ||
| import org.tron.consensus.base.Param.Miner; | ||
|
|
@@ -77,12 +80,47 @@ public void start() { | |
| } | ||
|
|
||
| param.setMiners(miners); | ||
| recordWitnessAddresses(miners); | ||
| recordIsWitness(); | ||
| param.setBlockHandle(blockHandle); | ||
| param.setPbftInterface(pbftBaseImpl); | ||
| consensus.start(param); | ||
| logger.info("consensus service start success"); | ||
| } | ||
|
|
||
| private void recordWitnessAddresses(List<Miner> miners) { | ||
| if (!Metrics.enabled() || miners == null) { | ||
| return; | ||
| } | ||
| for (Miner miner : miners) { | ||
| ByteString witnessAddress = miner.getWitnessAddress(); | ||
| try { | ||
| String address = StringUtil.encode58Check(witnessAddress.toByteArray()); | ||
| SRMetrics.recordWitnessAddress(address); | ||
| } catch (Exception e) { | ||
| logger.warn("Failed to record witness address metrics.", e); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can put
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The try/catch is intentionally kept inside the loop so that a failure for one witness address does not prevent the remaining addresses from being published. Moving it outside would stop processing at the first failure, so I’d prefer to keep the per-miner isolation here. |
||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Publishes tron:is_witness once at consensus startup; 0 = not witness, 1 = witness. It is | ||
| * published independently of the witness-address publication, and even when no miner is | ||
| * configured, so the flag series always exists. Catches its own failure so a metrics | ||
| * problem can neither skip the witness publication nor abort consensus startup. | ||
| */ | ||
| private void recordIsWitness() { | ||
| if (!Metrics.enabled()) { | ||
| return; | ||
| } | ||
| try { | ||
| SRMetrics.recordIsWitness(Args.getInstance().isWitness() | ||
| ? SRMetrics.WITNESS : SRMetrics.NOT_WITNESS); | ||
| } catch (Exception e) { | ||
| logger.warn("Failed to record is-witness metrics.", e); | ||
| } | ||
| } | ||
|
|
||
| public void stop() { | ||
| logger.info("consensus service closed start."); | ||
| consensus.stop(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.