-
Notifications
You must be signed in to change notification settings - Fork 151
Bug 1694715: Add testing against schema for the rate metric type #1529
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
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 |
|---|---|---|
|
|
@@ -8,7 +8,8 @@ use flate2::read::GzDecoder; | |
| use jsonschema_valid::{self, schemas::Draft}; | ||
| use serde_json::Value; | ||
|
|
||
| use glean::{ClientInfoMetrics, Configuration}; | ||
| use glean::private::{DenominatorMetric, NumeratorMetric, RateMetric}; | ||
| use glean::{ClientInfoMetrics, CommonMetricData, Configuration}; | ||
|
|
||
| const SCHEMA_JSON: &str = include_str!("../../../glean.1.schema.json"); | ||
|
|
||
|
|
@@ -88,8 +89,62 @@ fn validate_against_schema() { | |
| }; | ||
| let _ = new_glean(Some(cfg)); | ||
|
|
||
| // Define a new ping and submit it. | ||
| const PING_NAME: &str = "test-ping"; | ||
|
|
||
| // Test each of the metric types, just for basic smoke testing against the | ||
| // schema | ||
|
|
||
| // TODO: 1695762 Test all of the metric types against the schema from Rust | ||
|
|
||
| let rate_metric: RateMetric = RateMetric::new(CommonMetricData { | ||
| category: "test".into(), | ||
| name: "rate".into(), | ||
| send_in_pings: vec![PING_NAME.into()], | ||
| ..Default::default() | ||
| }); | ||
| rate_metric.add_to_numerator(1); | ||
| rate_metric.add_to_denominator(1); | ||
|
|
||
| let numerator_metric1: NumeratorMetric = NumeratorMetric::new(CommonMetricData { | ||
| category: "test".into(), | ||
| name: "num1".into(), | ||
| send_in_pings: vec![PING_NAME.into()], | ||
| ..Default::default() | ||
| }); | ||
| let numerator_metric2: NumeratorMetric = NumeratorMetric::new(CommonMetricData { | ||
| category: "test".into(), | ||
| name: "num2".into(), | ||
| send_in_pings: vec![PING_NAME.into()], | ||
| ..Default::default() | ||
| }); | ||
| let denominator_metric: DenominatorMetric = DenominatorMetric::new( | ||
| CommonMetricData { | ||
| category: "test".into(), | ||
| name: "den".into(), | ||
| send_in_pings: vec![PING_NAME.into()], | ||
| ..Default::default() | ||
| }, | ||
| vec![ | ||
| CommonMetricData { | ||
| category: "test".into(), | ||
| name: "num1".into(), | ||
| send_in_pings: vec![PING_NAME.into()], | ||
| ..Default::default() | ||
| }, | ||
| CommonMetricData { | ||
| category: "test".into(), | ||
| name: "num2".into(), | ||
| send_in_pings: vec![PING_NAME.into()], | ||
| ..Default::default() | ||
| }, | ||
| ], | ||
| ); | ||
|
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. @chutten pointed out in Matrix that maybe we should document how to make these in the developer docs. First, to confirm that this is correct, though...
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. This looks correct to me. |
||
|
|
||
| numerator_metric1.add_to_numerator(1); | ||
| numerator_metric2.add_to_numerator(2); | ||
| denominator_metric.add(3); | ||
|
|
||
| // Define a new ping and submit it. | ||
| let custom_ping = glean::private::PingType::new(PING_NAME, true, true, vec![]); | ||
| custom_ping.submit(None); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put the
categoryfirst so I can read it in the same order (test.rate) that it appears in the payload?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.