Skip to content

test(starknet_sequencer_metrics): add testing utilities to the metrics #4983

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

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

Yael-Starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@Yael-Starkware Yael-Starkware marked this pull request as ready for review March 17, 2025 15:20
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Yael-Starkware Yael-Starkware changed the title chore(m.m/.,m test(starknet_sequencer_metrics): add testing utilities to the metrics Mar 17, 2025
@Yael-Starkware Yael-Starkware force-pushed the yael/add_assert_eq_to_metrics branch from 34965be to 416c4be Compare March 17, 2025 15:23
Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions


crates/starknet_sequencer_metrics/src/metrics.rs line 146 at r2 (raw file):

        &self,
        metrics_as_string: &str,
        expected_value: u64,

I think this ought to be generic, like self.parse_numeric_metric is.

Code quote:

u64

crates/starknet_sequencer_metrics/src/metrics.rs line 311 at r2 (raw file):

        &self,
        metrics_as_string: &str,
        expected_value: f64,

Same?

Code quote:

f64

crates/starknet_sequencer_metrics/src/metrics.rs line 373 at r2 (raw file):

    pub fn parse_histogram_metric(&self, metrics_as_string: &str) -> Option<HistogramValue> {
        parse_histogram_metric(metrics_as_string, self.get_name(), None)
    }

Should also be under #[cfg(any(feature = "testing", test))]

Code quote:

    pub fn parse_histogram_metric(&self, metrics_as_string: &str) -> Option<HistogramValue> {
        parse_histogram_metric(metrics_as_string, self.get_name(), None)
    }

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @Yael-Starkware)


crates/starknet_sequencer_metrics/src/metrics.rs line 464 at r2 (raw file):

            expected_value,
            metric_value
        );

Is there a way to unify the code for the labeled and non-labeled cases?

Code quote:

    pub fn assert_eq(
        &self,
        metrics_as_string: &str,
        expected_value: &HistogramValue,
        label: &[(&'static str, &'static str)],
    ) {
        let metric_value = self.parse_histogram_metric(metrics_as_string, label).unwrap();
        assert!(
            metric_value.sum == expected_value.sum && metric_value.count == expected_value.count,
            "Metric histogram {} {:?} sum or count did not match the expected value. expected \
             value: {:?}, metric value: {:?}",
            self.get_name(),
            label,
            expected_value,
            metric_value
        );

@Yael-Starkware Yael-Starkware force-pushed the yael/add_assert_eq_to_metrics branch from 416c4be to d9860dc Compare March 18, 2025 11:01
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @Itay-Tsabary-Starkware)


crates/starknet_sequencer_metrics/src/metrics.rs line 311 at r2 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Same?

Done.


crates/starknet_sequencer_metrics/src/metrics.rs line 373 at r2 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Should also be under #[cfg(any(feature = "testing", test))]

Done.


crates/starknet_sequencer_metrics/src/metrics.rs line 464 at r2 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

Is there a way to unify the code for the labeled and non-labeled cases?

that was the reason I originally implemented this as a macro. it could treat counter, labeled_counter, gauge and labeled_gauge in one macro.

Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @Itay-Tsabary-Starkware)


crates/starknet_sequencer_metrics/src/metrics.rs line 146 at r2 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

I think this ought to be generic, like self.parse_numeric_metric is.

Done.

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 3 files at r1, 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)


crates/starknet_sequencer_metrics/src/metrics.rs line 464 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

that was the reason I originally implemented this as a macro. it could treat counter, labeled_counter, gauge and labeled_gauge in one macro.

I have a longshot idea on how to unify these without a macro, could you please add a todo on my name (tsabary) to try?

@Yael-Starkware Yael-Starkware force-pushed the yael/add_assert_eq_to_metrics branch from d9860dc to 659efc4 Compare March 18, 2025 11:41
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 5 files reviewed, all discussions resolved (waiting on @Itay-Tsabary-Starkware)


crates/starknet_sequencer_metrics/src/metrics.rs line 464 at r2 (raw file):

Previously, Itay-Tsabary-Starkware wrote…

I have a longshot idea on how to unify these without a macro, could you please add a todo on my name (tsabary) to try?

done

Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

@Yael-Starkware Yael-Starkware force-pushed the yael/add_assert_eq_to_metrics branch from 659efc4 to 99fbbcb Compare March 18, 2025 12:02
Copy link
Contributor

@Itay-Tsabary-Starkware Itay-Tsabary-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

@Yael-Starkware Yael-Starkware added this pull request to the merge queue Mar 19, 2025
Merged via the queue into main with commit d3363ab Mar 19, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants