From 4e3e7ba2502fd164f7a57185c7ea7287b75ece10 Mon Sep 17 00:00:00 2001 From: Chris H-C Date: Thu, 16 Sep 2021 18:03:51 +0000 Subject: [PATCH] Bug 1729723 - Update Glean to 41.0.0 r=TravisLong Differential Revision: https://phabricator.services.mozilla.com/D125456 --- Cargo.lock | 12 +- build.gradle | 2 +- .../rust/glean-core/.cargo-checksum.json | 2 +- third_party/rust/glean-core/Cargo.lock | 50 ++-- third_party/rust/glean-core/Cargo.toml | 13 +- .../rust/glean-core/src/database/mod.rs | 67 ++++- .../rust/glean-core/src/lib_unit_tests.rs | 1 + .../rust/glean-core/src/metrics/mod.rs | 6 + .../rust/glean-core/src/metrics/url.rs | 266 ++++++++++++++++++ third_party/rust/glean-core/src/traits/mod.rs | 2 + third_party/rust/glean-core/src/traits/url.rs | 57 ++++ .../rust/glean-ffi/.cargo-checksum.json | 2 +- third_party/rust/glean-ffi/Cargo.toml | 13 +- third_party/rust/glean-ffi/glean.h | 19 ++ third_party/rust/glean-ffi/src/lib.rs | 1 + third_party/rust/glean-ffi/src/url.rs | 49 ++++ third_party/rust/glean/.cargo-checksum.json | 2 +- third_party/rust/glean/Cargo.toml | 13 +- third_party/rust/glean/src/private/mod.rs | 2 + third_party/rust/glean/src/private/url.rs | 92 ++++++ toolkit/components/glean/Cargo.toml | 4 +- toolkit/components/glean/api/Cargo.toml | 2 +- 22 files changed, 617 insertions(+), 60 deletions(-) create mode 100644 third_party/rust/glean-core/src/metrics/url.rs create mode 100644 third_party/rust/glean-core/src/traits/url.rs create mode 100644 third_party/rust/glean-ffi/src/url.rs create mode 100644 third_party/rust/glean/src/private/url.rs diff --git a/Cargo.lock b/Cargo.lock index bf6b41f72308..ba85bc42cf4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1986,9 +1986,9 @@ dependencies = [ [[package]] name = "glean" -version = "40.1.0" +version = "41.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5a8f84d2fde6fd00464853df398213c29eab988406d6dd24ba610a24de96f5" +checksum = "4cc20bb4132c5ea3c0b26d855e7553e97ba2970c5bb57303fb7b3e06cc8c00d6" dependencies = [ "chrono", "crossbeam-channel", @@ -2006,9 +2006,9 @@ dependencies = [ [[package]] name = "glean-core" -version = "40.1.0" +version = "41.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b80bf28ad601449d6d159ddceb4ee5bb30fc229e6027f2c1488c248232e8c143" +checksum = "c5e4862e04b5a5c417b8d216cbae938762e59290f87c8e4b9a73f4c7511a7ac3" dependencies = [ "bincode", "chrono", @@ -2026,9 +2026,9 @@ dependencies = [ [[package]] name = "glean-ffi" -version = "40.1.0" +version = "41.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e68d41f1a8a06fe66cc8537f6286bf7a9e2f7868e1f776aaa4295f555d4390" +checksum = "db225c38d770bac6b8e6c6e88acbcca42e915bed49c790855b21fc619d00956d" dependencies = [ "android_logger", "env_logger", diff --git a/build.gradle b/build.gradle index 7975ed39dba1..fbd0230ee328 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ allprojects { topsrcdir = gradle.mozconfig.topsrcdir topobjdir = gradle.mozconfig.topobjdir - gleanVersion = "40.1.0" + gleanVersion = "41.0.0" if (gleanVersion != getRustVersionFor("glean")) { throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," + " found ${getRustVersionFor("glean")}") diff --git a/third_party/rust/glean-core/.cargo-checksum.json b/third_party/rust/glean-core/.cargo-checksum.json index 56c574ed0034..c559302e57ba 100644 --- a/third_party/rust/glean-core/.cargo-checksum.json +++ b/third_party/rust/glean-core/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"44116473805fcab8fb75b1278be14ae94adba7495e95fa1e9ed614424ce2a9c4","Cargo.toml":"8a799d5a686d69f49e6b6de11981f8024c5bac80689e23e063521df0212fd016","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"026495898699b54608eb4ec16074ffafc57920d80ccb59961c501a1ea28c9985","examples/sample.rs":"05469332ffa58c661628eb2f260dfd59085c371b0ef0f8b6e9cb77c230b9bb04","src/common_metric_data.rs":"0ce52740ab6d880df5127336ced68be30da568cd2a94301dc16d4e3f527134c9","src/coverage.rs":"49613fd310bd24d779472720975fbe6c97ec370a95eb55f10afa43f67539c942","src/database/mod.rs":"3a69b7e4581b308d71b9eca7798ad4bfccae313d46c74d6759df7e1b82bbe98a","src/debug.rs":"53b19f5a1ba8b35ab1ce78332cb2e8283b2068c9068d71c3be1f58bd8af792c3","src/error.rs":"97172a791efdf8b791a04ae7961085fbef4391b313ff3ffb24e9381f2901fccc","src/error_recording.rs":"42af60683cb30eba821b955fe156ce43a114c0f6f3f3b5b84566659398137671","src/event_database/mod.rs":"95d665a039236ede25dd479b19f0ddc32c0dd79cef2fbcc2ef3bab1540680276","src/histogram/exponential.rs":"389d48bab03f7229445ee4d4c8a4c49f6b43303f658dc954da75142f3c040dc6","src/histogram/functional.rs":"1a63a305b48bcef7bc38136b40d916df4bb8f098dc602514ada54a9b091f6951","src/histogram/linear.rs":"5642c8983c3c1ce9b69c6ac99133c8ed5e67abe2398c5dbcf67e69d66880f4ca","src/histogram/mod.rs":"11e5d3b6440a33a3e5544d0e03ffd69fa2fdcabe603ad75e0327f3ed548e8ce3","src/internal_metrics.rs":"5626effec67bf0f9ee12609b77cf04741eac1827123039999d4adb28a3cc5976","src/internal_pings.rs":"5ed4669b6f09d660401f44c8279e0a5fea0262e48de40e85595bd25dc70b05f3","src/lib.rs":"fe39588a966a9fbc5d01ab378b22a9e4318c37e514d40a5bdb72fbe49c691fe6","src/lib_unit_tests.rs":"a6f3dc822c5f9e39e4b7ed16a5d3bc66b57a138db5245ea5a8f2354020707364","src/macros.rs":"3f3fc8c36dd05b7528b66b27e95b6494505a7a1f48abd013218de23ada6b5a43","src/metrics/boolean.rs":"49e2f5be78055f61543db1d4d57cc06064a812a8f45c9d0e753df8325edc9041","src/metrics/counter.rs":"e3e2a195b597ea1559991b992f44a8a5f291b592a5c6946e93e01066f276efbb","src/metrics/custom_distribution.rs":"7ea1c54802e15bb490fdc8b396998ec474bfca2f135902a4028a9530fbb5dd98","src/metrics/datetime.rs":"75f0b7c41301eb881decff363947510a6cc1a9d2203357be32d1ee169c22ff4c","src/metrics/denominator.rs":"511e4123779a6d9159bb0911069f7dcb979899a0fae0d200da854685b59d3348","src/metrics/event.rs":"d6e4a52dbde7fbd44c21df567508c35acf046e08c6ea593bbb65fa25223a2b40","src/metrics/experiment.rs":"3f3ede015bb63fd5f71fc6a90421b25d8002faf71c0766b27bf59b5ae8b8d0da","src/metrics/jwe.rs":"8e1c2e204c285a428cf58f0e7d7ee0662294208b6b48706658a6f44cf412575a","src/metrics/labeled.rs":"c8ef8419447cc0f659eacfd685f6db806e38588bf4792ab97f468b9b23f644d8","src/metrics/memory_distribution.rs":"c2d75dfe9f67a21087b36af64816e703e6b56551b970fac642552116af97f2b5","src/metrics/memory_unit.rs":"d7a678e5242febd021283b30c0099a9e62729944816a3f17d2d91e2808bc0570","src/metrics/mod.rs":"bb82dc1b4ee627a589eb202ff704f86c6ba1861a1706ce0ff57fc70902415b9b","src/metrics/ping.rs":"b9d344cbfdbe8aff99a83423bd0af465a7228b503f92fe912ddac24904f4eca9","src/metrics/quantity.rs":"2eb6e34f7b0a292df26cddb4295bca7b82557320eff157bf854822c4a7fccb7e","src/metrics/rate.rs":"ba297a593d340568ee1f8061a6ba4f8970220ab2a83c7af290393538c6dd9bc4","src/metrics/string.rs":"8b47de25d4354c9ccf71a5558b287241a4d80c5832ac82e280543bb800996f54","src/metrics/string_list.rs":"c956616cfd1d0fce3c2e61f0b054235f455db2295d128f08b3db2ddcdd11bdbe","src/metrics/time_unit.rs":"9bb3f6c03b1d385008b254f36ed35daf22f9a6fa2d18e007c9b70aac767cde50","src/metrics/timespan.rs":"1252babc991f8c79cbd5027f3a332c28eb63fb0a956d19a18c670ab4f2e60ba3","src/metrics/timing_distribution.rs":"b885514ef2e84c970403f85bcdb09a24abf9822dbd78129fba9d37de388520a8","src/metrics/uuid.rs":"ebe5560fcc76b230d304172f0ab69dc3f5e41924dad8aa30090bd38b103d0ade","src/ping/mod.rs":"0d164c2ec2822658d571356f3d00f24410f9c1e63f31101fc5d0fb20a014ee1b","src/scheduler.rs":"829846308ae9ed558fbaa62e8134ec90571803673d304c8ce370de7117e1cc76","src/storage/mod.rs":"58fc22abaa2c3643a15992ea02c664909a8d6446e5a259044b4780895b2faf10","src/system.rs":"2e2a7436075bd1a34c118202a4d18e58236947696ce3d824e97d9c06ddf0c171","src/traits/boolean.rs":"f17f16f379b777e435e38e810e25336a919f4aeeefb1b4e7cf7749c0ef173fd9","src/traits/counter.rs":"631208036059d498a4485c74c2a80c24a5f13bffeb1053bdf5cce06af0e9d361","src/traits/custom_distribution.rs":"1b3ffda6e857bfa8ad5be412e88f3d9706ededf5a86407364ae19a81f06ef798","src/traits/datetime.rs":"2f4b9e64161c15c912b6a915045dd9840f76229d144a4d1542c54eb4f3b3406b","src/traits/event.rs":"ce9a9395748734b241f35b31c4cddf0ce6a8eca6d700aaeea427b0ae29ce507d","src/traits/jwe.rs":"80cdc61e6d99d7c05139c9d05288290c731b1be61afcbd4a4c415973665ea194","src/traits/labeled.rs":"7f3281fc0a1a745238e7e260463f397dfa61717408fe9d260dc9767d9c659e52","src/traits/memory_distribution.rs":"0b72ffde68eb97f01a57afbc5c6109565ec9435561984d34696622bf5a57d559","src/traits/mod.rs":"710640cb174dc740aeaf2f6dcc9fa6f184aaebc48fc108b39d482746ee7670f4","src/traits/numerator.rs":"9690a1b4487521565bd488e9a938aa66f93045c63f0f0ee6e864e0341395659b","src/traits/ping.rs":"8831c106c03afeb458b0b028fa1ce61f056ebf8e82bc0a171a1bff255d920748","src/traits/quantity.rs":"087d7a4b58f0eb7c766a0202dcf38a52d172ce4edf626211ffe5d94ed02ae754","src/traits/rate.rs":"9d0da25895d4c43cdece43dd57e515ab2fb907e8c9a239807976e3d9197d2955","src/traits/string.rs":"48e5623c7db59b8e6454fbc7fb6e2395f808c9a0fa721d7c07b72abb171eb1ad","src/traits/string_list.rs":"5d5773d5a130323dd82ca95f4ecdccdd6b237afe2eadf8655363bd6b7e8508c1","src/traits/timespan.rs":"29251233847c5cdd200a61472132c62ded27fe2c13835b09424384bf144d82db","src/traits/timing_distribution.rs":"5e619d445e6ef3f19ca69bcdfe02d19b150c5a46855d195703b6d2f55e538636","src/traits/uuid.rs":"bd78515611ba406d8b1bda35a9fe30c317512a9afcea7c5dece8fced7d410a92","src/upload/directory.rs":"571cfee0347b40b239d0d946625de6265bbea4f433c8316da715ded8f590aca1","src/upload/mod.rs":"34bcb67a5980e2c8b5145553b83e130ed4db40dab6d5c53bc9978469e6b93223","src/upload/policy.rs":"c250957a37783e74af8002cd80ba06ef9780a389fb0f61b8b665b79688f0a360","src/upload/request.rs":"7939e77bde4b55263446c3660b6831bafa27308bc983a51e1679321e962f372f","src/upload/result.rs":"d73454e81f185e4e28c887f7b496bffad7baac74c8f1b719885f940f909a530d","src/util.rs":"a89e21f0f4fe14a5a1a5369a0f2c20d1184816ccfe2b5b1599d3779660772f27","tests/boolean.rs":"9f4830f3b5f5ab6768060917deb1f546324a4744b8ed893197e31a0aed092947","tests/common/mod.rs":"28c77637c5e75a6a57c0aeb4b082de1b5d8015d507b557ca365aa5adbf208af8","tests/counter.rs":"39a2cd40335c164b3e7407f5505bbf571d7e4a71f032d476a7939f7dd1af90d0","tests/custom_distribution.rs":"596575504ad4eab2765b5b88245dcc92dc68e83d04c93deb4b27692c142c0b94","tests/datetime.rs":"4b4ab629a0f0ae789416b67f0efdfe1142fdb18f9d3a0b5182d8d840e4a6655c","tests/event.rs":"cb78dfc0a2315253da8ef6663b81979dd5b0638bb6c31456f16ce4e9bb50c67a","tests/jwe.rs":"dc8a73d1e1925ac49061e8bb5c8de01230aa364942a22470e37aa88965b0eaba","tests/labeled.rs":"cedd548bd8089dfa316cfdfaa1985fb5cd1294e6ba5956b6012c3f01975e8de9","tests/memory_distribution.rs":"0c03d0a491150f508dc12ecac7e5db70043f3a7de2f90cc6b3509aba90549821","tests/metrics.rs":"0560e0645321628015610bbf1a90c0adbb12ad42e5a068399073572120377cbb","tests/ping.rs":"a15c619b2d3c70c3cb669d02b959109bcf231440bdcfe3cac7508a3e310cd181","tests/ping_maker.rs":"aa7921c9dcea278003c719136eeea9b711d0be12bf736cc9a79b70b69cf6109f","tests/quantity.rs":"2543f0f57085d27b0bc0c25c24c17a7e376ac673cf9265a3a9dec202920679c5","tests/storage.rs":"d8d50aba92e17a3053fd80788f5fbbcc8f82293c11c19b58e2de6c4ee45f71ff","tests/string.rs":"9c3e21bfa3ad0b75373f8f5addb8ac023ac5336ac9f969e92b89ea6fda675fdd","tests/string_list.rs":"2b83710b949bea4bd0f6b2029069887f3ea87312b00091e5aa3c7bda0fb9073c","tests/timespan.rs":"bb61e4cfb843b3f387378409ee1a88ef4b8f32b2181af686baacee262b8bca2b","tests/timing_distribution.rs":"23f48e26cc4a9646c77a395fe724fa1c337caa69ea5c358056057cb1bbf4c7e6","tests/uuid.rs":"cf0df9e330344c6e00cd51faaf21dc74c5e47f892b525e0f83623c92a6378be8"},"package":"b80bf28ad601449d6d159ddceb4ee5bb30fc229e6027f2c1488c248232e8c143"} \ No newline at end of file +{"files":{"Cargo.lock":"588d3e6fa9cfbae716b3d3844582f87450dc4c39de1f7509de07d8d8276f6781","Cargo.toml":"821f04b20a9b2650534f24a3f2287589954735be4890e5b91d32fe6bf403cf8d","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"026495898699b54608eb4ec16074ffafc57920d80ccb59961c501a1ea28c9985","examples/sample.rs":"05469332ffa58c661628eb2f260dfd59085c371b0ef0f8b6e9cb77c230b9bb04","src/common_metric_data.rs":"0ce52740ab6d880df5127336ced68be30da568cd2a94301dc16d4e3f527134c9","src/coverage.rs":"49613fd310bd24d779472720975fbe6c97ec370a95eb55f10afa43f67539c942","src/database/mod.rs":"458e3c8af2af5345e02dea32b36f7521d4428c2ea65c225337008af56d00c6f6","src/debug.rs":"53b19f5a1ba8b35ab1ce78332cb2e8283b2068c9068d71c3be1f58bd8af792c3","src/error.rs":"97172a791efdf8b791a04ae7961085fbef4391b313ff3ffb24e9381f2901fccc","src/error_recording.rs":"42af60683cb30eba821b955fe156ce43a114c0f6f3f3b5b84566659398137671","src/event_database/mod.rs":"95d665a039236ede25dd479b19f0ddc32c0dd79cef2fbcc2ef3bab1540680276","src/histogram/exponential.rs":"389d48bab03f7229445ee4d4c8a4c49f6b43303f658dc954da75142f3c040dc6","src/histogram/functional.rs":"1a63a305b48bcef7bc38136b40d916df4bb8f098dc602514ada54a9b091f6951","src/histogram/linear.rs":"5642c8983c3c1ce9b69c6ac99133c8ed5e67abe2398c5dbcf67e69d66880f4ca","src/histogram/mod.rs":"11e5d3b6440a33a3e5544d0e03ffd69fa2fdcabe603ad75e0327f3ed548e8ce3","src/internal_metrics.rs":"5626effec67bf0f9ee12609b77cf04741eac1827123039999d4adb28a3cc5976","src/internal_pings.rs":"5ed4669b6f09d660401f44c8279e0a5fea0262e48de40e85595bd25dc70b05f3","src/lib.rs":"fe39588a966a9fbc5d01ab378b22a9e4318c37e514d40a5bdb72fbe49c691fe6","src/lib_unit_tests.rs":"17b0eaad81f946ddef89ee076f4d138e427638ee7536be128b30d4e7280dcf7b","src/macros.rs":"3f3fc8c36dd05b7528b66b27e95b6494505a7a1f48abd013218de23ada6b5a43","src/metrics/boolean.rs":"49e2f5be78055f61543db1d4d57cc06064a812a8f45c9d0e753df8325edc9041","src/metrics/counter.rs":"e3e2a195b597ea1559991b992f44a8a5f291b592a5c6946e93e01066f276efbb","src/metrics/custom_distribution.rs":"7ea1c54802e15bb490fdc8b396998ec474bfca2f135902a4028a9530fbb5dd98","src/metrics/datetime.rs":"75f0b7c41301eb881decff363947510a6cc1a9d2203357be32d1ee169c22ff4c","src/metrics/denominator.rs":"511e4123779a6d9159bb0911069f7dcb979899a0fae0d200da854685b59d3348","src/metrics/event.rs":"d6e4a52dbde7fbd44c21df567508c35acf046e08c6ea593bbb65fa25223a2b40","src/metrics/experiment.rs":"3f3ede015bb63fd5f71fc6a90421b25d8002faf71c0766b27bf59b5ae8b8d0da","src/metrics/jwe.rs":"8e1c2e204c285a428cf58f0e7d7ee0662294208b6b48706658a6f44cf412575a","src/metrics/labeled.rs":"c8ef8419447cc0f659eacfd685f6db806e38588bf4792ab97f468b9b23f644d8","src/metrics/memory_distribution.rs":"c2d75dfe9f67a21087b36af64816e703e6b56551b970fac642552116af97f2b5","src/metrics/memory_unit.rs":"d7a678e5242febd021283b30c0099a9e62729944816a3f17d2d91e2808bc0570","src/metrics/mod.rs":"069b6790de4abcaeb8ec06797a1e85344baff6b86844508b2d75d67eb00dc5d5","src/metrics/ping.rs":"b9d344cbfdbe8aff99a83423bd0af465a7228b503f92fe912ddac24904f4eca9","src/metrics/quantity.rs":"2eb6e34f7b0a292df26cddb4295bca7b82557320eff157bf854822c4a7fccb7e","src/metrics/rate.rs":"ba297a593d340568ee1f8061a6ba4f8970220ab2a83c7af290393538c6dd9bc4","src/metrics/string.rs":"8b47de25d4354c9ccf71a5558b287241a4d80c5832ac82e280543bb800996f54","src/metrics/string_list.rs":"c956616cfd1d0fce3c2e61f0b054235f455db2295d128f08b3db2ddcdd11bdbe","src/metrics/time_unit.rs":"9bb3f6c03b1d385008b254f36ed35daf22f9a6fa2d18e007c9b70aac767cde50","src/metrics/timespan.rs":"1252babc991f8c79cbd5027f3a332c28eb63fb0a956d19a18c670ab4f2e60ba3","src/metrics/timing_distribution.rs":"b885514ef2e84c970403f85bcdb09a24abf9822dbd78129fba9d37de388520a8","src/metrics/url.rs":"b83b1de16d2397fa31e52855ccc024a050c0b429af8ffb3ff1519b68b923241d","src/metrics/uuid.rs":"ebe5560fcc76b230d304172f0ab69dc3f5e41924dad8aa30090bd38b103d0ade","src/ping/mod.rs":"0d164c2ec2822658d571356f3d00f24410f9c1e63f31101fc5d0fb20a014ee1b","src/scheduler.rs":"829846308ae9ed558fbaa62e8134ec90571803673d304c8ce370de7117e1cc76","src/storage/mod.rs":"58fc22abaa2c3643a15992ea02c664909a8d6446e5a259044b4780895b2faf10","src/system.rs":"2e2a7436075bd1a34c118202a4d18e58236947696ce3d824e97d9c06ddf0c171","src/traits/boolean.rs":"f17f16f379b777e435e38e810e25336a919f4aeeefb1b4e7cf7749c0ef173fd9","src/traits/counter.rs":"631208036059d498a4485c74c2a80c24a5f13bffeb1053bdf5cce06af0e9d361","src/traits/custom_distribution.rs":"1b3ffda6e857bfa8ad5be412e88f3d9706ededf5a86407364ae19a81f06ef798","src/traits/datetime.rs":"2f4b9e64161c15c912b6a915045dd9840f76229d144a4d1542c54eb4f3b3406b","src/traits/event.rs":"ce9a9395748734b241f35b31c4cddf0ce6a8eca6d700aaeea427b0ae29ce507d","src/traits/jwe.rs":"80cdc61e6d99d7c05139c9d05288290c731b1be61afcbd4a4c415973665ea194","src/traits/labeled.rs":"7f3281fc0a1a745238e7e260463f397dfa61717408fe9d260dc9767d9c659e52","src/traits/memory_distribution.rs":"0b72ffde68eb97f01a57afbc5c6109565ec9435561984d34696622bf5a57d559","src/traits/mod.rs":"88cec83fcff8dfab768953b901ee95fed186f7540afdc9606407aff71f1919df","src/traits/numerator.rs":"9690a1b4487521565bd488e9a938aa66f93045c63f0f0ee6e864e0341395659b","src/traits/ping.rs":"8831c106c03afeb458b0b028fa1ce61f056ebf8e82bc0a171a1bff255d920748","src/traits/quantity.rs":"087d7a4b58f0eb7c766a0202dcf38a52d172ce4edf626211ffe5d94ed02ae754","src/traits/rate.rs":"9d0da25895d4c43cdece43dd57e515ab2fb907e8c9a239807976e3d9197d2955","src/traits/string.rs":"48e5623c7db59b8e6454fbc7fb6e2395f808c9a0fa721d7c07b72abb171eb1ad","src/traits/string_list.rs":"5d5773d5a130323dd82ca95f4ecdccdd6b237afe2eadf8655363bd6b7e8508c1","src/traits/timespan.rs":"29251233847c5cdd200a61472132c62ded27fe2c13835b09424384bf144d82db","src/traits/timing_distribution.rs":"5e619d445e6ef3f19ca69bcdfe02d19b150c5a46855d195703b6d2f55e538636","src/traits/url.rs":"a01331623af4fa8af6e71becffff60060832bef5e48a15df6dc23b41225f689e","src/traits/uuid.rs":"bd78515611ba406d8b1bda35a9fe30c317512a9afcea7c5dece8fced7d410a92","src/upload/directory.rs":"571cfee0347b40b239d0d946625de6265bbea4f433c8316da715ded8f590aca1","src/upload/mod.rs":"34bcb67a5980e2c8b5145553b83e130ed4db40dab6d5c53bc9978469e6b93223","src/upload/policy.rs":"c250957a37783e74af8002cd80ba06ef9780a389fb0f61b8b665b79688f0a360","src/upload/request.rs":"7939e77bde4b55263446c3660b6831bafa27308bc983a51e1679321e962f372f","src/upload/result.rs":"d73454e81f185e4e28c887f7b496bffad7baac74c8f1b719885f940f909a530d","src/util.rs":"a89e21f0f4fe14a5a1a5369a0f2c20d1184816ccfe2b5b1599d3779660772f27","tests/boolean.rs":"9f4830f3b5f5ab6768060917deb1f546324a4744b8ed893197e31a0aed092947","tests/common/mod.rs":"28c77637c5e75a6a57c0aeb4b082de1b5d8015d507b557ca365aa5adbf208af8","tests/counter.rs":"39a2cd40335c164b3e7407f5505bbf571d7e4a71f032d476a7939f7dd1af90d0","tests/custom_distribution.rs":"596575504ad4eab2765b5b88245dcc92dc68e83d04c93deb4b27692c142c0b94","tests/datetime.rs":"4b4ab629a0f0ae789416b67f0efdfe1142fdb18f9d3a0b5182d8d840e4a6655c","tests/event.rs":"cb78dfc0a2315253da8ef6663b81979dd5b0638bb6c31456f16ce4e9bb50c67a","tests/jwe.rs":"dc8a73d1e1925ac49061e8bb5c8de01230aa364942a22470e37aa88965b0eaba","tests/labeled.rs":"cedd548bd8089dfa316cfdfaa1985fb5cd1294e6ba5956b6012c3f01975e8de9","tests/memory_distribution.rs":"0c03d0a491150f508dc12ecac7e5db70043f3a7de2f90cc6b3509aba90549821","tests/metrics.rs":"0560e0645321628015610bbf1a90c0adbb12ad42e5a068399073572120377cbb","tests/ping.rs":"a15c619b2d3c70c3cb669d02b959109bcf231440bdcfe3cac7508a3e310cd181","tests/ping_maker.rs":"aa7921c9dcea278003c719136eeea9b711d0be12bf736cc9a79b70b69cf6109f","tests/quantity.rs":"2543f0f57085d27b0bc0c25c24c17a7e376ac673cf9265a3a9dec202920679c5","tests/storage.rs":"d8d50aba92e17a3053fd80788f5fbbcc8f82293c11c19b58e2de6c4ee45f71ff","tests/string.rs":"9c3e21bfa3ad0b75373f8f5addb8ac023ac5336ac9f969e92b89ea6fda675fdd","tests/string_list.rs":"2b83710b949bea4bd0f6b2029069887f3ea87312b00091e5aa3c7bda0fb9073c","tests/timespan.rs":"bb61e4cfb843b3f387378409ee1a88ef4b8f32b2181af686baacee262b8bca2b","tests/timing_distribution.rs":"23f48e26cc4a9646c77a395fe724fa1c337caa69ea5c358056057cb1bbf4c7e6","tests/uuid.rs":"cf0df9e330344c6e00cd51faaf21dc74c5e47f892b525e0f83623c92a6378be8"},"package":"c5e4862e04b5a5c417b8d216cbae938762e59290f87c8e4b9a73f4c7511a7ac3"} \ No newline at end of file diff --git a/third_party/rust/glean-core/Cargo.lock b/third_party/rust/glean-core/Cargo.lock index 688f1ac6ae3a..ae1c5c02bc8b 100644 --- a/third_party/rust/glean-core/Cargo.lock +++ b/third_party/rust/glean-core/Cargo.lock @@ -54,9 +54,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" [[package]] name = "cfg-if" @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d" +checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" dependencies = [ "quote", "syn", @@ -121,9 +121,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" dependencies = [ "cfg-if", "crc32fast", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "glean-core" -version = "40.1.0" +version = "41.0.0" dependencies = [ "bincode", "chrono", @@ -229,9 +229,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.100" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fa8cddc8fbbee11227ef194b5317ed014b8acbf15139bd716a18ad3fe99ec5" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" [[package]] name = "lmdb-rkv" @@ -376,9 +376,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] @@ -481,18 +481,18 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "serde" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.129" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -501,9 +501,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" +checksum = "a7f9e390c27c3c0ce8bc5d725f6e4d30a29d26659494aa4b17535f7522c5c950" dependencies = [ "itoa", "ryu", @@ -512,9 +512,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.75" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" +checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" dependencies = [ "proc-macro2", "quote", @@ -546,18 +546,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" dependencies = [ "proc-macro2", "quote", @@ -576,9 +576,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" +checksum = "5241dd6f21443a3606b432718b166d3cedc962fd4b8bea54a8bc7f514ebda986" dependencies = [ "tinyvec_macros", ] diff --git a/third_party/rust/glean-core/Cargo.toml b/third_party/rust/glean-core/Cargo.toml index c61e97acf229..c0fa203a41e1 100644 --- a/third_party/rust/glean-core/Cargo.toml +++ b/third_party/rust/glean-core/Cargo.toml @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "glean-core" -version = "40.1.0" +version = "41.0.0" authors = ["Jan-Erik Rediger ", "The Glean Team "] include = ["/README.md", "/LICENSE", "/src", "/examples", "/tests", "/Cargo.toml"] description = "A modern Telemetry library" @@ -22,7 +21,7 @@ keywords = ["telemetry"] license = "MPL-2.0" repository = "https://github.com/mozilla/glean" [package.metadata.glean] -glean-parser = "3.6.0" +glean-parser = "4.0.0" [dependencies.bincode] version = "1.2.1" diff --git a/third_party/rust/glean-core/src/database/mod.rs b/third_party/rust/glean-core/src/database/mod.rs index 399a32b877aa..e1e3373ff12b 100644 --- a/third_party/rust/glean-core/src/database/mod.rs +++ b/third_party/rust/glean-core/src/database/mod.rs @@ -643,7 +643,7 @@ impl Database { ping_lifetime_data .write() .expect("Can't access ping lifetime data as writable") - .clear(); + .retain(|metric_id, _| !metric_id.starts_with(storage_name)); } self.write_with_store(Lifetime::Ping, |mut writer, store| { @@ -1321,6 +1321,71 @@ mod test { } } + #[test] + fn test_delayed_ping_lifetime_clear() { + // Init the database in a temporary directory. + let dir = tempdir().unwrap(); + let db = Database::new(dir.path(), true).unwrap(); + let test_storage = "test-storage"; + + assert!(db.ping_lifetime_data.is_some()); + + // Attempt to record a known value. + let test_value1 = "test-value1"; + let test_metric_id1 = "telemetry_test.test_name1"; + db.record_per_lifetime( + Lifetime::Ping, + test_storage, + test_metric_id1, + &Metric::String(test_value1.to_string()), + ) + .unwrap(); + + { + let data = match &db.ping_lifetime_data { + Some(ping_lifetime_data) => ping_lifetime_data, + None => panic!("Expected `ping_lifetime_data` to exist here!"), + }; + let data = data.read().unwrap(); + // Verify that test_value1 is in memory. + assert!(data + .get(&format!("{}#{}", test_storage, test_metric_id1)) + .is_some()); + } + + // Clear ping lifetime storage for a storage that isn't test_storage. + // Doesn't matter what it's called, just that it isn't test_storage. + db.clear_ping_lifetime_storage(&(test_storage.to_owned() + "x")) + .unwrap(); + + { + let data = match &db.ping_lifetime_data { + Some(ping_lifetime_data) => ping_lifetime_data, + None => panic!("Expected `ping_lifetime_data` to exist here!"), + }; + let data = data.read().unwrap(); + // Verify that test_value1 is still in memory. + assert!(data + .get(&format!("{}#{}", test_storage, test_metric_id1)) + .is_some()); + } + + // Clear test_storage's ping lifetime storage. + db.clear_ping_lifetime_storage(test_storage).unwrap(); + + { + let data = match &db.ping_lifetime_data { + Some(ping_lifetime_data) => ping_lifetime_data, + None => panic!("Expected `ping_lifetime_data` to exist here!"), + }; + let data = data.read().unwrap(); + // Verify that test_value1 is no longer in memory. + assert!(data + .get(&format!("{}#{}", test_storage, test_metric_id1)) + .is_none()); + } + } + #[test] fn doesnt_record_when_upload_is_disabled() { let (mut glean, dir) = new_glean(None); diff --git a/third_party/rust/glean-core/src/lib_unit_tests.rs b/third_party/rust/glean-core/src/lib_unit_tests.rs index 1a12ea2d4da2..6e94a921ec91 100644 --- a/third_party/rust/glean-core/src/lib_unit_tests.rs +++ b/third_party/rust/glean-core/src/lib_unit_tests.rs @@ -438,6 +438,7 @@ fn correct_order() { MemoryDistribution(..) => assert_eq!(12, disc), Jwe(..) => assert_eq!(13, disc), Rate(..) => assert_eq!(14, disc), + Url(..) => assert_eq!(15, disc), } } } diff --git a/third_party/rust/glean-core/src/metrics/mod.rs b/third_party/rust/glean-core/src/metrics/mod.rs index d1756f5019d4..5ac24f3d1eb8 100644 --- a/third_party/rust/glean-core/src/metrics/mod.rs +++ b/third_party/rust/glean-core/src/metrics/mod.rs @@ -29,6 +29,7 @@ mod string_list; mod time_unit; mod timespan; mod timing_distribution; +mod url; mod uuid; pub use crate::event_database::RecordedEvent; @@ -63,6 +64,7 @@ pub use self::time_unit::TimeUnit; pub use self::timespan::TimespanMetric; pub use self::timing_distribution::TimerId; pub use self::timing_distribution::TimingDistributionMetric; +pub use self::url::UrlMetric; pub use self::uuid::UuidMetric; /// A snapshot of all buckets and the accumulated sum of a distribution. @@ -121,6 +123,8 @@ pub enum Metric { Jwe(String), /// A rate metric. See [`RateMetric`] for more information. Rate(i32, i32), + /// A URL metric. See [`UrlMetric`] for more information. + Url(String), } /// A [`MetricType`] describes common behavior across all metrics. @@ -160,6 +164,7 @@ impl Metric { Metric::StringList(_) => "string_list", Metric::Timespan(..) => "timespan", Metric::TimingDistribution(_) => "timing_distribution", + Metric::Url(_) => "url", Metric::Uuid(_) => "uuid", Metric::MemoryDistribution(_) => "memory_distribution", Metric::Jwe(_) => "jwe", @@ -187,6 +192,7 @@ impl Metric { json!({"value": time_unit.duration_convert(*time), "time_unit": time_unit}) } Metric::TimingDistribution(hist) => json!(timing_distribution::snapshot(hist)), + Metric::Url(s) => json!(s), Metric::Uuid(s) => json!(s), Metric::MemoryDistribution(hist) => json!(memory_distribution::snapshot(hist)), Metric::Jwe(s) => json!(s), diff --git a/third_party/rust/glean-core/src/metrics/url.rs b/third_party/rust/glean-core/src/metrics/url.rs new file mode 100644 index 000000000000..3f3fdd17daaa --- /dev/null +++ b/third_party/rust/glean-core/src/metrics/url.rs @@ -0,0 +1,266 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use crate::error_recording::{record_error, ErrorType}; +use crate::metrics::Metric; +use crate::metrics::MetricType; +use crate::storage::StorageManager; +use crate::CommonMetricData; +use crate::Glean; + +// The maximum number of characters a URL Metric may have, before encoding. +const MAX_URL_LENGTH: usize = 2048; + +/// A URL metric. +/// +/// Record an Unicode string value a URL content. +/// The URL is length-limited to `MAX_URL_LENGTH` bytes. +#[derive(Clone, Debug)] +pub struct UrlMetric { + meta: CommonMetricData, +} + +impl MetricType for UrlMetric { + fn meta(&self) -> &CommonMetricData { + &self.meta + } + + fn meta_mut(&mut self) -> &mut CommonMetricData { + &mut self.meta + } +} + +// IMPORTANT: +// +// When changing this implementation, make sure all the operations are +// also declared in the related trait in `../traits/`. +impl UrlMetric { + /// Creates a new string metric. + pub fn new(meta: CommonMetricData) -> Self { + Self { meta } + } + + fn is_valid_url_scheme(&self, value: String) -> bool { + let mut splits = value.split(':'); + if let Some(scheme) = splits.next() { + if scheme.is_empty() { + return false; + } + let mut chars = scheme.chars(); + // The list of characters allowed in the scheme is on + // the spec here: https://url.spec.whatwg.org/#url-scheme-string + return chars.next().unwrap().is_ascii_alphabetic() + && chars.all(|c| c.is_ascii_alphanumeric() || ['+', '-', '.'].contains(&c)); + } + + // No ':' found, this is not valid :) + false + } + + /// Sets to the specified stringified URL. + /// + /// # Arguments + /// + /// * `glean` - The Glean instance this metric belongs to. + /// * `value` - The stringified URL to set the metric to. + /// + /// ## Notes + /// + /// Truncates the value if it is longer than `MAX_URL_LENGTH` bytes and logs an error. + pub fn set>(&self, glean: &Glean, value: S) { + if !self.should_record(glean) { + return; + } + + let s = value.into(); + if s.len() > MAX_URL_LENGTH { + let msg = format!( + "Value length {} exceeds maximum of {}", + s.len(), + MAX_URL_LENGTH + ); + record_error(glean, &self.meta, ErrorType::InvalidOverflow, msg, None); + return; + } + + if s.starts_with("data:") { + record_error( + glean, + &self.meta, + ErrorType::InvalidValue, + "URL metric does not support data URLs.", + None, + ); + return; + } + + if !self.is_valid_url_scheme(s.clone()) { + let msg = format!("\"{}\" does not start with a valid URL scheme.", s); + record_error(glean, &self.meta, ErrorType::InvalidValue, msg, None); + return; + } + + let value = Metric::Url(s); + glean.storage().record(glean, &self.meta, &value) + } + + /// **Test-only API (exported for FFI purposes).** + /// + /// Gets the currently stored value as a string. + /// + /// This doesn't clear the stored value. + pub fn test_get_value(&self, glean: &Glean, storage_name: &str) -> Option { + match StorageManager.snapshot_metric_for_test( + glean.storage(), + storage_name, + &self.meta.identifier(glean), + self.meta.lifetime, + ) { + Some(Metric::Url(s)) => Some(s), + _ => None, + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::test_get_num_recorded_errors; + use crate::tests::new_glean; + use crate::ErrorType; + use crate::Lifetime; + + #[test] + fn payload_is_correct() { + let (glean, _) = new_glean(None); + + let metric = UrlMetric::new(CommonMetricData { + name: "url_metric".into(), + category: "test".into(), + send_in_pings: vec!["store1".into()], + lifetime: Lifetime::Application, + disabled: false, + dynamic_label: None, + }); + + let sample_url = "glean://test".to_string(); + metric.set(&glean, sample_url.clone()); + assert_eq!(sample_url, metric.test_get_value(&glean, "store1").unwrap()); + } + + #[test] + fn does_not_record_url_exceeding_maximum_length() { + let (glean, _) = new_glean(None); + + let metric = UrlMetric::new(CommonMetricData { + name: "url_metric".into(), + category: "test".into(), + send_in_pings: vec!["store1".into()], + lifetime: Lifetime::Application, + disabled: false, + dynamic_label: None, + }); + + let long_path = "testing".repeat(2000); + let test_url = format!("glean://{}", long_path); + metric.set(&glean, test_url); + + assert!(metric.test_get_value(&glean, "store1").is_none()); + + assert_eq!( + 1, + test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidOverflow, None) + .unwrap() + ); + } + + #[test] + fn does_not_record_data_urls() { + let (glean, _) = new_glean(None); + + let metric = UrlMetric::new(CommonMetricData { + name: "url_metric".into(), + category: "test".into(), + send_in_pings: vec!["store1".into()], + lifetime: Lifetime::Application, + disabled: false, + dynamic_label: None, + }); + + let test_url = "data:application/json"; + metric.set(&glean, test_url); + + assert!(metric.test_get_value(&glean, "store1").is_none()); + + assert_eq!( + 1, + test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None) + .unwrap() + ); + } + + #[test] + fn url_validation_works_and_records_errors() { + let (glean, _) = new_glean(None); + + let metric = UrlMetric::new(CommonMetricData { + name: "url_metric".into(), + category: "test".into(), + send_in_pings: vec!["store1".into()], + lifetime: Lifetime::Application, + disabled: false, + dynamic_label: None, + }); + + let incorrects = vec![ + "", + // Scheme may only start with upper or lowercase ASCII alpha[^1] character. + // [1]: https://infra.spec.whatwg.org/#ascii-alpha + "1glean://test", + "-glean://test", + // Scheme may only have ASCII alphanumeric characters or the `-`, `.`, `+` characters. + "шеллы://test", + "g!lean://test", + "g=lean://test", + // Scheme must be followed by `:` character. + "glean//test", + ]; + + let corrects = vec![ + // The minimum URL + "g:", + // Empty body is fine + "glean://", + // "//" is actually not even necessary + "glean:", + "glean:test", + "glean:test.com", + // Scheme may only have ASCII alphanumeric characters or the `-`, `.`, `+` characters. + "g-lean://test", + "g+lean://test", + "g.lean://test", + // Query parameters are fine + "glean://test?hello=world", + // Finally, some actual real world URLs + "https://infra.spec.whatwg.org/#ascii-alpha", + "https://infra.spec.whatwg.org/#ascii-alpha?test=for-glean", + ]; + + for incorrect in incorrects.clone().into_iter() { + metric.set(&glean, incorrect); + assert!(metric.test_get_value(&glean, "store1").is_none()); + } + + assert_eq!( + incorrects.len(), + test_get_num_recorded_errors(&glean, metric.meta(), ErrorType::InvalidValue, None) + .unwrap() as usize + ); + + for correct in corrects.into_iter() { + metric.set(&glean, correct); + assert_eq!(metric.test_get_value(&glean, "store1").unwrap(), correct); + } + } +} diff --git a/third_party/rust/glean-core/src/traits/mod.rs b/third_party/rust/glean-core/src/traits/mod.rs index 23f7df2fad81..6a15c415d463 100644 --- a/third_party/rust/glean-core/src/traits/mod.rs +++ b/third_party/rust/glean-core/src/traits/mod.rs @@ -23,6 +23,7 @@ mod string; mod string_list; mod timespan; mod timing_distribution; +mod url; mod uuid; pub use self::boolean::Boolean; @@ -44,5 +45,6 @@ pub use self::string::String; pub use self::string_list::StringList; pub use self::timespan::Timespan; pub use self::timing_distribution::TimingDistribution; +pub use self::url::Url; pub use self::uuid::Uuid; pub use crate::histogram::HistogramType; diff --git a/third_party/rust/glean-core/src/traits/url.rs b/third_party/rust/glean-core/src/traits/url.rs new file mode 100644 index 000000000000..4f43b406e8dd --- /dev/null +++ b/third_party/rust/glean-core/src/traits/url.rs @@ -0,0 +1,57 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use crate::ErrorType; + +/// A description for the [`UrlMetric`](crate::metrics::UrlMetric) type. +/// +/// When changing this trait, make sure all the operations are +/// implemented in the related type in `../metrics/`. +pub trait Url { + /// Sets to the specified stringified URL. + /// + /// # Arguments + /// + /// * `glean` - The Glean instance this metric belongs to. + /// * `value` - The stringified URL to set the metric to. + /// + /// ## Notes + /// + /// Truncates the value if it is longer than `MAX_URL_LENGTH` bytes and logs an error. + fn set>(&self, value: S); + + /// **Exported for test purposes.** + /// + /// Gets the currently stored value as a string. + /// + /// This doesn't clear the stored value. + /// + /// # Arguments + /// + /// * `ping_name` - represents the optional name of the ping to retrieve the + /// metric for. Defaults to the first value in `send_in_pings`. + fn test_get_value<'a, S: Into>>( + &self, + ping_name: S, + ) -> Option; + + /// **Exported for test purposes.** + /// + /// Gets the number of recorded errors for the given metric and error type. + /// + /// # Arguments + /// + /// * `error` - The type of error + /// * `ping_name` - represents the optional name of the ping to retrieve the + /// metric for. Defaults to the first value in `send_in_pings`. + /// + /// # Returns + /// + /// The number of errors reported. + fn test_get_num_recorded_errors<'a, S: Into>>( + &self, + error: ErrorType, + ping_name: S, + ) -> i32; +} diff --git a/third_party/rust/glean-ffi/.cargo-checksum.json b/third_party/rust/glean-ffi/.cargo-checksum.json index 31034dc29e06..73bcfb607e93 100644 --- a/third_party/rust/glean-ffi/.cargo-checksum.json +++ b/third_party/rust/glean-ffi/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"cea028c99a84abf0e6bde7126532ada339f2e07f266c48151604c2c6c3fd61eb","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"bfe00cc2501c9b15d5bc463c6db30ebbf8d7b5d6c555cf3827ae529fc9e7d6cc","cbindgen.toml":"ac25d1bc2ab7d6afaf25cfa0d35233f93b01f7129088cdd1fa89b9d987a8c564","glean.h":"591e297a1a9abcd3b517c291cadc507fae773f6777f536709cbef3eb63a394f9","src/boolean.rs":"0d1d59d0c13cdb63592a9513f2abcf3d1a8260d6523cc7d1af40cfcb4c75572a","src/byte_buffer.rs":"eeb6df25da7b393517f0c993e1e99a0acbccd7678b1127ce0e471d0e53a4bb45","src/counter.rs":"4d8f41285e4a9dbfa2733cdf937905006b475c0af7a501df73fde4ca77818e82","src/custom_distribution.rs":"b0b3b23289e413e7d150e8dae8217e6bd409cbbab68abb127f146041bcbfaf45","src/datetime.rs":"a5c1c993605b1a8ff044d88de4f4a385aff1a781cb8cb45573b90882da801fae","src/event.rs":"ef6dd4f0493ae223e4f7091d5779e46b33ea9864c2a4e5953811a7d9e8884c32","src/fd_logger.rs":"0f8197bb086f49413cca30a72bae029f663842fc3b78ceef6d0854a070b1cdfd","src/ffi_string_ext.rs":"389ae94dcdace1f56ca2c87207e865edda6d42da45733f1027e0a4dcfa86c492","src/from_raw.rs":"b17515a58d7e303ee746ea54c1c1c6d0523dc4de0bd8157dfaba2a610da637bb","src/handlemap_ext.rs":"3b1b088a2de197a0c3eaae0f2f0915d53602f51c13d27f48297f52cd885d5abc","src/jwe.rs":"72adff64900ca16d6527e8d6a436ac2ba85f738d6e92e33f3d71df32b485d0c3","src/labeled.rs":"93630c68c00b0b9fa74ff2483fbf92bb62620ec003705d495381dbddadbb5c54","src/lib.rs":"b74fd1c6c880a1eaf75972feceef15219cc4a8a0b25bb911ebec0981e3cbd97a","src/macros.rs":"e11614edb156552617354d7f6120c8e60ffeb6632ebc19d2b7c6c3e88523b01b","src/memory_distribution.rs":"08ef15e340f2e7ab2f4f83cd8e883c864d4affb94458e80198c106393bfb6bd8","src/ping_type.rs":"6401bcf4342ec1e4ba3782e2b67b3320aa96c9eddc03fc3c75ecc54e2f08a619","src/quantity.rs":"f72781ea642b5f7e363e9fecaded143d1afd772575603763543f1df3448ec337","src/string.rs":"199a238f3524eb36643d82b63df5c7f013adedb6af80632a2675f8562f34e692","src/string_list.rs":"12e2fbbdc08a1b8da1885fb14acd59ab27c8b598a24dc15a4eaca16636540a54","src/timespan.rs":"b7ac51dbfd5169d8c688c3fd2db51e38b6173c925ca14d7b0e8353f225b30a50","src/timing_distribution.rs":"4b5962729fb0b4c9ebf65a5fc5af105357652fcc282c6f8840f328452ba86ac6","src/upload.rs":"320c6e97df0a87040d2a269765401cd67da50f0a226c95a9a314f22452116f7c","src/uuid.rs":"c9ea7225fac53b55a8aeef39cd33470228c0a178185aa74b8fa652657994e404","src/weak.rs":"0199f4ef38d667f0b9f8ef3c5505ff15cd6e911bc83c27e7e9954fdffe1be0bb"},"package":"58e68d41f1a8a06fe66cc8537f6286bf7a9e2f7868e1f776aaa4295f555d4390"} \ No newline at end of file +{"files":{"Cargo.toml":"1b3394031e70ceced5c904a7a8ca591cd2238c7f7ecea9ec452a5a23e605ab47","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"bfe00cc2501c9b15d5bc463c6db30ebbf8d7b5d6c555cf3827ae529fc9e7d6cc","cbindgen.toml":"ac25d1bc2ab7d6afaf25cfa0d35233f93b01f7129088cdd1fa89b9d987a8c564","glean.h":"bbe571147f9fee34f7deac1057c541f00523317328e591446d4c96bbe84c99eb","src/boolean.rs":"0d1d59d0c13cdb63592a9513f2abcf3d1a8260d6523cc7d1af40cfcb4c75572a","src/byte_buffer.rs":"eeb6df25da7b393517f0c993e1e99a0acbccd7678b1127ce0e471d0e53a4bb45","src/counter.rs":"4d8f41285e4a9dbfa2733cdf937905006b475c0af7a501df73fde4ca77818e82","src/custom_distribution.rs":"b0b3b23289e413e7d150e8dae8217e6bd409cbbab68abb127f146041bcbfaf45","src/datetime.rs":"a5c1c993605b1a8ff044d88de4f4a385aff1a781cb8cb45573b90882da801fae","src/event.rs":"ef6dd4f0493ae223e4f7091d5779e46b33ea9864c2a4e5953811a7d9e8884c32","src/fd_logger.rs":"0f8197bb086f49413cca30a72bae029f663842fc3b78ceef6d0854a070b1cdfd","src/ffi_string_ext.rs":"389ae94dcdace1f56ca2c87207e865edda6d42da45733f1027e0a4dcfa86c492","src/from_raw.rs":"b17515a58d7e303ee746ea54c1c1c6d0523dc4de0bd8157dfaba2a610da637bb","src/handlemap_ext.rs":"3b1b088a2de197a0c3eaae0f2f0915d53602f51c13d27f48297f52cd885d5abc","src/jwe.rs":"72adff64900ca16d6527e8d6a436ac2ba85f738d6e92e33f3d71df32b485d0c3","src/labeled.rs":"93630c68c00b0b9fa74ff2483fbf92bb62620ec003705d495381dbddadbb5c54","src/lib.rs":"2da192f73f5882156a731ba8ee56847dc6bcff6607667238da07fecc31052e64","src/macros.rs":"e11614edb156552617354d7f6120c8e60ffeb6632ebc19d2b7c6c3e88523b01b","src/memory_distribution.rs":"08ef15e340f2e7ab2f4f83cd8e883c864d4affb94458e80198c106393bfb6bd8","src/ping_type.rs":"6401bcf4342ec1e4ba3782e2b67b3320aa96c9eddc03fc3c75ecc54e2f08a619","src/quantity.rs":"f72781ea642b5f7e363e9fecaded143d1afd772575603763543f1df3448ec337","src/string.rs":"199a238f3524eb36643d82b63df5c7f013adedb6af80632a2675f8562f34e692","src/string_list.rs":"12e2fbbdc08a1b8da1885fb14acd59ab27c8b598a24dc15a4eaca16636540a54","src/timespan.rs":"b7ac51dbfd5169d8c688c3fd2db51e38b6173c925ca14d7b0e8353f225b30a50","src/timing_distribution.rs":"4b5962729fb0b4c9ebf65a5fc5af105357652fcc282c6f8840f328452ba86ac6","src/upload.rs":"320c6e97df0a87040d2a269765401cd67da50f0a226c95a9a314f22452116f7c","src/url.rs":"2dfaf006cd4024ee07eb37dc312201b027d774f6c9881e556774cc09077a6290","src/uuid.rs":"c9ea7225fac53b55a8aeef39cd33470228c0a178185aa74b8fa652657994e404","src/weak.rs":"0199f4ef38d667f0b9f8ef3c5505ff15cd6e911bc83c27e7e9954fdffe1be0bb"},"package":"db225c38d770bac6b8e6c6e88acbcca42e915bed49c790855b21fc619d00956d"} \ No newline at end of file diff --git a/third_party/rust/glean-ffi/Cargo.toml b/third_party/rust/glean-ffi/Cargo.toml index 1bf97f3c30f0..0d9002ca3850 100644 --- a/third_party/rust/glean-ffi/Cargo.toml +++ b/third_party/rust/glean-ffi/Cargo.toml @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "glean-ffi" -version = "40.1.0" +version = "41.0.0" authors = ["Jan-Erik Rediger ", "The Glean Team "] include = ["/README.md", "/LICENSE", "/src", "/tests", "/Cargo.toml", "/cbindgen.toml", "/glean.h"] description = "FFI layer for Glean, a modern Telemetry library" @@ -29,7 +28,7 @@ crate-type = ["lib"] version = "0.4.0" [dependencies.glean-core] -version = "40.1.0" +version = "41.0.0" [dependencies.log] version = "0.4.8" diff --git a/third_party/rust/glean-ffi/glean.h b/third_party/rust/glean-ffi/glean.h index 3992d1616b15..ede0f960ccb3 100644 --- a/third_party/rust/glean-ffi/glean.h +++ b/third_party/rust/glean-ffi/glean.h @@ -790,6 +790,25 @@ uint8_t glean_timing_distribution_test_has_value(uint64_t metric_id, FfiStr stor char *glean_timing_distribution_test_get_value_as_json_string(uint64_t metric_id, FfiStr storage_name); +void glean_destroy_url_metric(uint64_t v); + +uint64_t glean_new_url_metric(FfiStr category, + FfiStr name, + RawStringArray send_in_pings, + int32_t send_in_pings_len, + Lifetime lifetime, + uint8_t disabled); + +int32_t glean_url_test_get_num_recorded_errors(uint64_t metric_id, + int32_t error_type, + FfiStr storage_name); + +void glean_url_set(uint64_t metric_id, FfiStr value); + +uint8_t glean_url_test_has_value(uint64_t metric_id, FfiStr storage_name); + +char *glean_url_test_get_value(uint64_t metric_id, FfiStr storage_name); + void glean_destroy_uuid_metric(uint64_t v); uint64_t glean_new_uuid_metric(FfiStr category, diff --git a/third_party/rust/glean-ffi/src/lib.rs b/third_party/rust/glean-ffi/src/lib.rs index 9618c2f2a533..1c5148f552c0 100644 --- a/third_party/rust/glean-ffi/src/lib.rs +++ b/third_party/rust/glean-ffi/src/lib.rs @@ -42,6 +42,7 @@ mod string_list; mod timespan; mod timing_distribution; pub mod upload; +mod url; mod uuid; #[cfg(all(not(target_os = "android"), not(target_os = "ios")))] diff --git a/third_party/rust/glean-ffi/src/url.rs b/third_party/rust/glean-ffi/src/url.rs new file mode 100644 index 000000000000..6a54db6a2fa3 --- /dev/null +++ b/third_party/rust/glean-ffi/src/url.rs @@ -0,0 +1,49 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::os::raw::c_char; + +use ffi_support::FfiStr; + +use crate::{ + define_metric, ffi_string_ext::FallibleToString, handlemap_ext::HandleMapExtension, + with_glean_value, Lifetime, +}; + +define_metric!(UrlMetric => URL_METRICS { + new -> glean_new_url_metric(), + test_get_num_recorded_errors -> glean_url_test_get_num_recorded_errors, + destroy -> glean_destroy_url_metric, +}); + +#[no_mangle] +pub extern "C" fn glean_url_set(metric_id: u64, value: FfiStr) { + with_glean_value(|glean| { + URL_METRICS.call_with_log(metric_id, |metric| { + let value = value.to_string_fallible()?; + metric.set(glean, value); + Ok(()) + }) + }) +} + +#[no_mangle] +pub extern "C" fn glean_url_test_has_value(metric_id: u64, storage_name: FfiStr) -> u8 { + with_glean_value(|glean| { + URL_METRICS.call_infallible(metric_id, |metric| { + metric + .test_get_value(glean, storage_name.as_str()) + .is_some() + }) + }) +} + +#[no_mangle] +pub extern "C" fn glean_url_test_get_value(metric_id: u64, storage_name: FfiStr) -> *mut c_char { + with_glean_value(|glean| { + URL_METRICS.call_infallible(metric_id, |metric| { + metric.test_get_value(glean, storage_name.as_str()).unwrap() + }) + }) +} diff --git a/third_party/rust/glean/.cargo-checksum.json b/third_party/rust/glean/.cargo-checksum.json index 9454b7dd928b..a56799488a6b 100644 --- a/third_party/rust/glean/.cargo-checksum.json +++ b/third_party/rust/glean/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"94101531a189b89a5bc97b3b7d54f17d8790451c01d98818c078d993a3039996","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"fd9e0ca6907917ea6bec5de05e15dd21d20fae1cb7f3250467bb20231a8e1065","src/common_test.rs":"bd7ab2f6384bea8971f97ba68b11c946899303891bc534898f7aabbf27f9008a","src/configuration.rs":"4acbedba16d45f6404ccedde86e8aa33eea8c1b9554210cb69c79ff2ec9040c9","src/core_metrics.rs":"0593192ec0fa1b4d267411cdfb75c70f78578083eca91f6e09cd08346de32264","src/dispatcher/global.rs":"6dae43ceb6bb8f5c6f20311ce610e4173eb880b4314aafd5791be03240a72096","src/dispatcher/mod.rs":"3254ad8f33439c1c0159e3e5b63f028f9e1a4a6c069c6d73dd82bd9cfe3e6086","src/glean_metrics.rs":"151b6e5acc12436c33c75e2e0a18f9769179d3c7fdc60a22fa02afb76feaf00f","src/lib.rs":"d31e11a0101d500173a1f91f9c0187c4418a9c0420e610d34b6a6cfa9260969a","src/net/http_uploader.rs":"9e8c1837ca0d3f6ea165ec936ab054173c4fe95a958710176c33b4d4d1d98beb","src/net/mod.rs":"284bcf182156c52ea25fa33bcc48d80b4970ee3c187a4ea3a06602cc34c710bf","src/pings.rs":"2dfccd84848e1933aa4f6a7a707c58ec794c8f73ef2d93ea4d4df71d4e6abc31","src/private/boolean.rs":"eeadc0529e2c69a930479f208746799b064b27facab8306c1c10c650e83fb63c","src/private/counter.rs":"0bc8a2d0df72e47b7365ff80bfc16427a5da701fd0adadeedbcce13cebcd79ce","src/private/custom_distribution.rs":"6d1271fb91e9d51a8dcf5eb9d540b3757ebe9cc998b196943ed8c729f62afc67","src/private/datetime.rs":"cb8f26f74d318e2118d6ae1b15972557eb205d4d8b24795fb0d08fdea2bc3f56","src/private/denominator.rs":"95332737f3ac80346f4811440a2141cd427692819bd04d5d3ac7374299dc20b0","src/private/event.rs":"b674ceb85351b7989bd25ed4f5d98c5c9b31e2a03f13b054a8c0dbef54190e49","src/private/labeled.rs":"2cd90d132954ee3ada43ff1ad538072ba43eece7a53ed89811a2a7b43a4819f1","src/private/memory_distribution.rs":"8b78a0e33601081d76639445c8b4875a4fe7c3aded720bb43afdabe86e0fd6ee","src/private/mod.rs":"413a41942a48de3d39e9346c2a0803a3ce184978173f8a79b13a116be4abaffe","src/private/numerator.rs":"334ac2ad3d8dd7b9f02f1ca5391b683d50fbc8c6728a12882a68bb067604c800","src/private/ping.rs":"915fc42994e0929656daee5511946ac1f56fe0d4d704e97e13795771d9890180","src/private/quantity.rs":"528675cd388010b89e6ac23c9152701c78d32c2dcd0b5e9abf1a50a52ee818a5","src/private/rate.rs":"7ddfdb3d5f2d1887b378caa3769ade92ea0fbd193f6e760f5f383c8b3e9f3aff","src/private/recorded_experiment_data.rs":"66b2601902a2dc2b7a283717c21ce754de94fcca30d12e0398195c8ad49c90af","src/private/string.rs":"c85ded40b1409793ae5b78da692bc2e708f8d55defb76ec5f515096d32f206c9","src/private/string_list.rs":"472ad79fba4b9bcde0ff5b3e05fd8e0aaa3d1d2941fc181faf2ceb90f1d518bd","src/private/timespan.rs":"19ed08aa5103b685a3a0b9f06f2c60250d55f3c8f36337f8c7bdbb2dfdb92786","src/private/timing_distribution.rs":"ee7fa0c3d5427e371b5413373cb1f5841ac10df9b7ca08316ef724e7ad3591d9","src/private/uuid.rs":"2b69ddaf3978aaa31c625c0f3eb948c44369744334aacc6b5a2b217268d244a7","src/system.rs":"ff23a5b94f52dab484342dfed702412bc29ab1bbfd5af326033d8e07e7b9075f","src/test.rs":"0cbe4f51fa01b1ca04e4b726e8eb729c3504086bc6b0d644e2114a5a4473165a","tests/common/mod.rs":"4837df2e771929cc077e6fb9a9239645e8e0f7bc6c9f409b71c4d147edf334fc","tests/init_fails.rs":"1e832fe454962ddb1155d546bb71b6395aa9936f848ff0fbe88affaaab7dfae3","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"4d61e4196d8eef23f3bcb24b59bd0b0379c1f2cb50f03434a53996ab097bfb17","tests/overflowing_preinit.rs":"81ff97745789fd5f58f86364488c011b4503648f1366b12e26755edc54323150","tests/schema.rs":"621caef0cc7f98c79740422835485fea2343ca105d0d9a7eec6ded9cfad6232c","tests/simple.rs":"2f58d3ff90005231f2febd21f66ee41d06302618408ea990b446510449c3444f"},"package":"6e5a8f84d2fde6fd00464853df398213c29eab988406d6dd24ba610a24de96f5"} \ No newline at end of file +{"files":{"Cargo.toml":"487e553304087d20edb2497858a4bb401dcd95cc4db81e5ea29a399a42c75900","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"fd9e0ca6907917ea6bec5de05e15dd21d20fae1cb7f3250467bb20231a8e1065","src/common_test.rs":"bd7ab2f6384bea8971f97ba68b11c946899303891bc534898f7aabbf27f9008a","src/configuration.rs":"4acbedba16d45f6404ccedde86e8aa33eea8c1b9554210cb69c79ff2ec9040c9","src/core_metrics.rs":"0593192ec0fa1b4d267411cdfb75c70f78578083eca91f6e09cd08346de32264","src/dispatcher/global.rs":"6dae43ceb6bb8f5c6f20311ce610e4173eb880b4314aafd5791be03240a72096","src/dispatcher/mod.rs":"3254ad8f33439c1c0159e3e5b63f028f9e1a4a6c069c6d73dd82bd9cfe3e6086","src/glean_metrics.rs":"151b6e5acc12436c33c75e2e0a18f9769179d3c7fdc60a22fa02afb76feaf00f","src/lib.rs":"d31e11a0101d500173a1f91f9c0187c4418a9c0420e610d34b6a6cfa9260969a","src/net/http_uploader.rs":"9e8c1837ca0d3f6ea165ec936ab054173c4fe95a958710176c33b4d4d1d98beb","src/net/mod.rs":"284bcf182156c52ea25fa33bcc48d80b4970ee3c187a4ea3a06602cc34c710bf","src/pings.rs":"2dfccd84848e1933aa4f6a7a707c58ec794c8f73ef2d93ea4d4df71d4e6abc31","src/private/boolean.rs":"eeadc0529e2c69a930479f208746799b064b27facab8306c1c10c650e83fb63c","src/private/counter.rs":"0bc8a2d0df72e47b7365ff80bfc16427a5da701fd0adadeedbcce13cebcd79ce","src/private/custom_distribution.rs":"6d1271fb91e9d51a8dcf5eb9d540b3757ebe9cc998b196943ed8c729f62afc67","src/private/datetime.rs":"cb8f26f74d318e2118d6ae1b15972557eb205d4d8b24795fb0d08fdea2bc3f56","src/private/denominator.rs":"95332737f3ac80346f4811440a2141cd427692819bd04d5d3ac7374299dc20b0","src/private/event.rs":"b674ceb85351b7989bd25ed4f5d98c5c9b31e2a03f13b054a8c0dbef54190e49","src/private/labeled.rs":"2cd90d132954ee3ada43ff1ad538072ba43eece7a53ed89811a2a7b43a4819f1","src/private/memory_distribution.rs":"8b78a0e33601081d76639445c8b4875a4fe7c3aded720bb43afdabe86e0fd6ee","src/private/mod.rs":"63368b123fecb6de210ec634b8d387799b4b9dd960016335ebc3c6851e81628f","src/private/numerator.rs":"334ac2ad3d8dd7b9f02f1ca5391b683d50fbc8c6728a12882a68bb067604c800","src/private/ping.rs":"915fc42994e0929656daee5511946ac1f56fe0d4d704e97e13795771d9890180","src/private/quantity.rs":"528675cd388010b89e6ac23c9152701c78d32c2dcd0b5e9abf1a50a52ee818a5","src/private/rate.rs":"7ddfdb3d5f2d1887b378caa3769ade92ea0fbd193f6e760f5f383c8b3e9f3aff","src/private/recorded_experiment_data.rs":"66b2601902a2dc2b7a283717c21ce754de94fcca30d12e0398195c8ad49c90af","src/private/string.rs":"c85ded40b1409793ae5b78da692bc2e708f8d55defb76ec5f515096d32f206c9","src/private/string_list.rs":"472ad79fba4b9bcde0ff5b3e05fd8e0aaa3d1d2941fc181faf2ceb90f1d518bd","src/private/timespan.rs":"19ed08aa5103b685a3a0b9f06f2c60250d55f3c8f36337f8c7bdbb2dfdb92786","src/private/timing_distribution.rs":"ee7fa0c3d5427e371b5413373cb1f5841ac10df9b7ca08316ef724e7ad3591d9","src/private/url.rs":"223de8a025e2f749255103402eecb5582961c2b5af7492e294362a0e8f55c414","src/private/uuid.rs":"2b69ddaf3978aaa31c625c0f3eb948c44369744334aacc6b5a2b217268d244a7","src/system.rs":"ff23a5b94f52dab484342dfed702412bc29ab1bbfd5af326033d8e07e7b9075f","src/test.rs":"0cbe4f51fa01b1ca04e4b726e8eb729c3504086bc6b0d644e2114a5a4473165a","tests/common/mod.rs":"4837df2e771929cc077e6fb9a9239645e8e0f7bc6c9f409b71c4d147edf334fc","tests/init_fails.rs":"1e832fe454962ddb1155d546bb71b6395aa9936f848ff0fbe88affaaab7dfae3","tests/never_init.rs":"1f33b8ce7ca3514b57b48cc16d98408974c85cf8aa7d13257ffc2ad878ebb295","tests/no_time_to_init.rs":"4d61e4196d8eef23f3bcb24b59bd0b0379c1f2cb50f03434a53996ab097bfb17","tests/overflowing_preinit.rs":"81ff97745789fd5f58f86364488c011b4503648f1366b12e26755edc54323150","tests/schema.rs":"621caef0cc7f98c79740422835485fea2343ca105d0d9a7eec6ded9cfad6232c","tests/simple.rs":"2f58d3ff90005231f2febd21f66ee41d06302618408ea990b446510449c3444f"},"package":"4cc20bb4132c5ea3c0b26d855e7553e97ba2970c5bb57303fb7b3e06cc8c00d6"} \ No newline at end of file diff --git a/third_party/rust/glean/Cargo.toml b/third_party/rust/glean/Cargo.toml index 6a75fb3e18ec..602b5df564a2 100644 --- a/third_party/rust/glean/Cargo.toml +++ b/third_party/rust/glean/Cargo.toml @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "glean" -version = "40.1.0" +version = "41.0.0" authors = ["Jan-Erik Rediger ", "The Glean Team "] include = ["/README.md", "/LICENSE", "/src", "/tests", "/Cargo.toml"] description = "Glean SDK Rust language bindings" @@ -29,7 +28,7 @@ features = ["serde"] version = "0.5" [dependencies.glean-core] -version = "40.1.0" +version = "41.0.0" [dependencies.inherent] version = "0.1.4" diff --git a/third_party/rust/glean/src/private/mod.rs b/third_party/rust/glean/src/private/mod.rs index 05e405704899..ae59c15d05f1 100644 --- a/third_party/rust/glean/src/private/mod.rs +++ b/third_party/rust/glean/src/private/mod.rs @@ -21,6 +21,7 @@ mod string; mod string_list; mod timespan; mod timing_distribution; +mod url; mod uuid; pub use self::uuid::UuidMetric; @@ -41,3 +42,4 @@ pub use string::StringMetric; pub use string_list::StringListMetric; pub use timespan::TimespanMetric; pub use timing_distribution::TimingDistributionMetric; +pub use url::UrlMetric; diff --git a/third_party/rust/glean/src/private/url.rs b/third_party/rust/glean/src/private/url.rs new file mode 100644 index 000000000000..ce595ecd960e --- /dev/null +++ b/third_party/rust/glean/src/private/url.rs @@ -0,0 +1,92 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use inherent::inherent; +use std::sync::Arc; + +use glean_core::metrics::MetricType; +use glean_core::ErrorType; + +// We need to wrap the glean-core type, otherwise if we try to implement +// the trait for the metric in `glean_core::metrics` we hit error[E0117]: +// only traits defined in the current crate can be implemented for arbitrary +// types. + +/// Developer-facing API for recording URL metrics. +/// +/// Instances of this class type are automatically generated by the parsers +/// at build time, allowing developers to record values that were previously +/// registered in the metrics.yaml file. +#[derive(Clone)] +pub struct UrlMetric(pub(crate) Arc); + +impl UrlMetric { + /// The public constructor used by automatically generated metrics. + #[allow(dead_code)] + pub fn new(meta: glean_core::CommonMetricData) -> Self { + Self(Arc::new(glean_core::metrics::UrlMetric::new(meta))) + } +} + +#[inherent(pub)] +impl glean_core::traits::Url for UrlMetric { + fn set>(&self, value: S) { + let metric = Arc::clone(&self.0); + let new_value = value.into(); + crate::launch_with_glean(move |glean| metric.set(glean, new_value)); + } + + fn test_get_value<'a, S: Into>>( + &self, + ping_name: S, + ) -> Option { + crate::block_on_dispatcher(); + + let queried_ping_name = ping_name + .into() + .unwrap_or_else(|| &self.0.meta().send_in_pings[0]); + + crate::with_glean(|glean| self.0.test_get_value(glean, queried_ping_name)) + } + + fn test_get_num_recorded_errors<'a, S: Into>>( + &self, + error: ErrorType, + ping_name: S, + ) -> i32 { + crate::block_on_dispatcher(); + + crate::with_glean_mut(|glean| { + glean_core::test_get_num_recorded_errors(glean, self.0.meta(), error, ping_name.into()) + .unwrap_or(0) + }) + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common_test::{lock_test, new_glean}; + use crate::CommonMetricData; + + #[test] + fn url_smoke() { + let _lock = lock_test(); + let _t = new_glean(None, true); + + let metric: UrlMetric = UrlMetric::new(CommonMetricData { + name: "url".into(), + category: "test".into(), + send_in_pings: vec!["test1".into()], + ..Default::default() + }); + + metric.set("rlb://test"); + + assert_eq!( + metric.test_get_num_recorded_errors(ErrorType::InvalidValue, None), + 0 + ); + } +} diff --git a/toolkit/components/glean/Cargo.toml b/toolkit/components/glean/Cargo.toml index 92e0c5add2cb..a9dd6b871396 100644 --- a/toolkit/components/glean/Cargo.toml +++ b/toolkit/components/glean/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "MPL-2.0" [dependencies] -glean = { version = "40.1.0", features = ["rkv-safe-mode"] } +glean = { version = "41.0.0", features = ["rkv-safe-mode"] } # In theory we only need this for `target_os = "android"` builds. # Cargo has the ability to do that with `[target.'cfg(target_os = "android")'.dependencies]`. # However that seems to confuse `cbindgen` quite a lot; @@ -15,7 +15,7 @@ glean = { version = "40.1.0", features = ["rkv-safe-mode"] } # So for now we unconditionally depend on it, but in the code we only `extern crate` it on Android builds. # While `glean-ffi` is still built (I think it is), # it's not linked into the final library. -glean-ffi = "40.1.0" +glean-ffi = "41.0.0" log = "0.4" nserror = { path = "../../../xpcom/rust/nserror" } nsstring = { path = "../../../xpcom/rust/nsstring" } diff --git a/toolkit/components/glean/api/Cargo.toml b/toolkit/components/glean/api/Cargo.toml index 03bf0ad16084..ec3e1cbad566 100644 --- a/toolkit/components/glean/api/Cargo.toml +++ b/toolkit/components/glean/api/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] bincode = "1.0" chrono = "0.4.10" -glean = "40.1.0" +glean = "41.0.0" inherent = "0.1.4" log = "0.4" nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }