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

Add a histogram for tcp events based on Event type #3064

Closed
wants to merge 3 commits into from

Conversation

miazn
Copy link
Contributor

@miazn miazn commented Feb 7, 2024

Motivation

To better understand what is going on in SnarkOS TCP land, it may be beneficial to create a histogram (1 metric in Prometheus) that shows count and sum in bytes of each Event Message type, so this PR adds one called snarkos_tcp_gateway_messages_received, with dynamic labeling based on the event name, in the Decoder impl of the EventCodec. I am using the basic metrics rust crate to call the histogram macro, however it appears that in SnarkVM this functionality is overridden by the implementation of the snarkVM metrics crate, so I figured the easiest thing to do was to just add an alias for the default crate.

Note, the histogram! macro used currently only needs to be called once, so we don't need to register the metrics in /node/metrics/src/names.rs, which might be worth revisiting at a later date.

Test Plan

Run on local devnets

Screenshot 2024-02-07 at 10 44 48 PM

cli/src/commands/start.rs Outdated Show resolved Hide resolved
cli/src/commands/start.rs Outdated Show resolved Hide resolved
Comment on lines +39 to +42
[dependencies.metrics_external]
version = "0.22"
package = "metrics"

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert

Ok(event) => Ok(Some(event)),
Ok(event) => {
#[cfg(feature = "metrics")]
histogram!(metrics::tcp::TCP_GATEWAY, "event" => event.name()).record(bytes_len);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the histogram from snarkvm_metrics

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In snarkvm_metrics, you can only update a histogram with a static name and value, which would require creating a separate metric name for every event type-- using just the regular histogram macro allows you to add labels which keeps the number of separate metrics lower and allows for easier analysis in Prometheus
I tried to call the original metrics crate histogram macro from here but it looked like I would need to add it to expose it in the snarkvm_metrics crate 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks for the clarification! I'll take a look at this when things are more stable.

@@ -21,6 +21,7 @@ use rayon::{
iter::{IndexedParallelIterator, ParallelIterator},
prelude::ParallelSlice,
};
use metrics_external::histogram;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert

@miazn
Copy link
Contributor Author

miazn commented Feb 15, 2024

closing this in favor of https://github.com/AleoHQ/snarkOS/pull/3097

@miazn miazn closed this Feb 15, 2024
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.

None yet

2 participants