-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend metrics in the code base (#684)
* Adding metrics to other services * Adding block proposed and received metrics * Enable custom ghcr images (#683) * feat: allow devs to publish images from branches * feat: publshing docker images on master commits, pre-release, and release * fix: typo * Update .github/workflows/on-master-commit.yaml Co-authored-by: Pedro Gomes <[email protected]> * Update .github/workflows/on-master-commit.yaml Co-authored-by: Pedro Gomes <[email protected]> * fix: remove duplication * chore: update actions versions * feat: orchestract pull request CI from one file * feat: orchestract pull request CI from one file * fix: typos * fix: remove requirement for test to pass before testing docker build * Update .github/workflows/on-master-commit.yaml Co-authored-by: libotony <[email protected]> * Update .github/workflows/on-pre-release.yaml Co-authored-by: libotony <[email protected]> * chore: add linter to pre-master publish * feat: throw an error for invalid release tag * feat: throw an error for invalid release tag * fix: publish only rc for pre-release" * fix: pre-release regex * fix: remove duplication * feat: verify tags/releases * fix: validate step * chore: update to use ref_name instead of ref * Update .github/workflows/on-release.yaml Co-authored-by: libotony <[email protected]> * Update .github/workflows/on-pull-request.yaml Co-authored-by: libotony <[email protected]> * chore: updates for PR comments --------- Co-authored-by: Pedro Gomes <[email protected]> Co-authored-by: libotony <[email protected]> * adding p2p, txpool, bft metrics * lazyloading metrics * adding lazyloading tests + quality of life funcs * Fixing histogram buckets * minor cleanups * fix the no label in the gauge --------- Co-authored-by: Darren Kelly <[email protected]> Co-authored-by: libotony <[email protected]>
- Loading branch information
1 parent
f500ae7
commit 06c6e78
Showing
15 changed files
with
292 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package node | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/vechain/thor/v2/telemetry" | ||
) | ||
|
||
var ( | ||
metricBlockProposedCount = telemetry.LazyLoadCounterVec("block_proposed_count", []string{"status"}) | ||
metricBlockProposedTxs = telemetry.LazyLoadCounterVec("block_proposed_tx_count", []string{"status"}) | ||
metricBlockProposedDuration = telemetry.LazyLoadHistogramVec( | ||
"block_proposed_duration_ms", []string{"status"}, telemetry.Bucket10s, | ||
) | ||
|
||
metricBlockReceivedCount = telemetry.LazyLoadCounterVec("block_received_count", []string{"status"}) | ||
metricBlockReceivedProcessedTxs = telemetry.LazyLoadCounterVec("block_received_processed_tx_count", []string{"status"}) | ||
metricBlockReceivedDuration = telemetry.LazyLoadHistogramVec( | ||
"block_received_duration_ms", []string{"status"}, telemetry.Bucket10s, | ||
) | ||
|
||
metricChainForkCount = telemetry.LazyLoadCounter("chain_fork_count") | ||
metricChainForkSize = telemetry.LazyLoadGauge("chain_fork_size") | ||
) | ||
|
||
func evalBlockReceivedMetrics(f func() error) error { | ||
startTime := time.Now() | ||
|
||
if err := f(); err != nil { | ||
status := map[string]string{ | ||
"status": "failed", | ||
} | ||
metricBlockReceivedCount().AddWithLabel(1, status) | ||
metricBlockReceivedDuration().ObserveWithLabels(time.Since(startTime).Milliseconds(), status) | ||
return err | ||
} | ||
|
||
status := map[string]string{ | ||
"status": "received", | ||
} | ||
metricBlockReceivedCount().AddWithLabel(1, status) | ||
metricBlockReceivedDuration().ObserveWithLabels(time.Since(startTime).Milliseconds(), status) | ||
return nil | ||
} | ||
|
||
// evalBlockProposeMetrics captures block proposing metrics | ||
func evalBlockProposeMetrics(f func() error) error { | ||
startTime := time.Now() | ||
|
||
if err := f(); err != nil { | ||
status := map[string]string{ | ||
"status": "failed", | ||
} | ||
metricBlockProposedCount().AddWithLabel(1, status) | ||
metricBlockProposedDuration().ObserveWithLabels(time.Since(startTime).Milliseconds(), status) | ||
return err | ||
} | ||
|
||
status := map[string]string{ | ||
"status": "proposed", | ||
} | ||
metricBlockProposedCount().AddWithLabel(1, status) | ||
metricBlockProposedDuration().ObserveWithLabels(time.Since(startTime).Milliseconds(), status) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package p2psrv | ||
|
||
import "github.com/vechain/thor/v2/telemetry" | ||
|
||
var ( | ||
metricConnectedPeers = telemetry.LazyLoadGauge("p2p_connected_peers_count") | ||
metricDiscoveredNodes = telemetry.LazyLoadGauge("p2p_discovered_node_count") | ||
metricDialNewNode = telemetry.LazyLoadCounter("p2p_dial_new_node_count") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.