Skip to content
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

feat(metrics): add chain info metrics #2386

Merged
merged 7 commits into from
Sep 23, 2024
Merged

feat(metrics): add chain info metrics #2386

merged 7 commits into from
Sep 23, 2024

Conversation

kmd-fl
Copy link
Contributor

@kmd-fl kmd-fl commented Sep 23, 2024

Description

Add a chain info metric with chain configuration

Proposed Changes

  • Refactor a bit to remove server-config dependency on peer-metrics. It turned out to be useless in this PR, but maybe will be helpful in the next one with more configs
  • Add current_commitment_status. The status is a number which corresponds to the CCStatus enum in chain_listener.
  • Add nox_chain_info metric. Example:
# HELP nox_chain Chain Nox Info.
# TYPE nox_chain info
nox_chain_info{peer_id="0x123",http_endpoint="http://localhost:8545",diamond_contract_address="0x123",network_id="1",default_base_fee="1",default_priority_fee="1",ws_endpoint="ws://localhost:8546",proof_poll_period="1s",min_batch_count="1",max_batch_count="1",max_proof_batch_size="1",epoch_end_window="1s"} 1
# EOF

@kmd-fl kmd-fl requested a review from folex September 23, 2024 14:05
use prometheus_client::metrics::info::Info;
use prometheus_client::registry::Registry;

pub struct NoxInfo {
pub versions: NoxVersions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was expecting array here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? NoxVersions implement the EncodeLabelSet which creates the array automatically from the structure fields and values

}

impl ChainInfo {
pub fn empty(peer_id: String) -> ChainInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, maybe. I would expect that default is what implements Default, and I'm not sure if this thing should implement default, but whatever

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea to move empty to Default implementation, that's the rust way of things

sub_registry.register("chain", "Chain Nox Info", chain_info);
}

pub fn add_info_metrics2(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 2? maybe remove 1st?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, forgot the remove

Copy link
Member

@folex folex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc status in the next pr?

@folex folex merged commit 53b7609 into master Sep 23, 2024
11 checks passed
@folex folex deleted the chain-info-metrics branch September 23, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants