From b484598b68a4f28ffad3fce077c8b8a4b4633907 Mon Sep 17 00:00:00 2001 From: Pierre Massat Date: Thu, 25 Jul 2024 15:25:36 -0400 Subject: [PATCH] fix: Fix build with Rust 1.80 (#3866) #skip-changelog --- Cargo.lock | 37 ++++++++++++++++--- relay-base-schema/src/project.rs | 4 +- relay-dynamic-config/src/global.rs | 4 -- relay-event-normalization/Cargo.toml | 1 + .../src/normalize/user_agent.rs | 1 - relay-event-schema/src/protocol/debugmeta.rs | 4 +- relay-filter/src/config.rs | 16 ++++---- relay-filter/src/generic.rs | 8 ++-- relay-server/src/extractors/forwarded_for.rs | 2 +- relay-server/src/services/global_config.rs | 2 +- relay-server/src/services/project_cache.rs | 6 +-- relay-server/src/statsd.rs | 4 +- .../test_fixtures__event_schema.snap | 4 +- 13 files changed, 57 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e6b42f148..e3c4e4a731 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1041,6 +1041,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -2749,6 +2758,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.46" @@ -3176,6 +3191,12 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -5404,11 +5425,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -5416,16 +5440,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] diff --git a/relay-base-schema/src/project.rs b/relay-base-schema/src/project.rs index c47790de89..73c32a70d4 100644 --- a/relay-base-schema/src/project.rs +++ b/relay-base-schema/src/project.rs @@ -1,9 +1,9 @@ //! Contains [`ProjectKey`] and [`ProjectId`] types and necessary traits implementations. //! //! - [`ProjectId`] is the unique identifier of a Sentry project. Currently, it is just a wrapper -//! over `u64` and should be considered as implementations details, as it can change in the future. +//! over `u64` and should be considered as implementations details, as it can change in the future. //! - [`ProjectKey`] is a byte array (`[u8; 32]`) and represents a DSN to identify and authenticate -//! a project at Sentry. +//! a project at Sentry. use std::error::Error; use std::fmt; diff --git a/relay-dynamic-config/src/global.rs b/relay-dynamic-config/src/global.rs index 35e950da7a..982eb86024 100644 --- a/relay-dynamic-config/src/global.rs +++ b/relay-dynamic-config/src/global.rs @@ -19,7 +19,6 @@ use crate::{defaults, ErrorBoundary, MetricExtractionGroup, MetricExtractionGrou /// [`ProjectConfig`](crate::ProjectConfig)s small. #[derive(Default, Clone, Debug, Serialize, Deserialize)] #[serde(default, rename_all = "camelCase")] -#[cfg_attr(feature = "jsonschema", derive(JsonSchema))] pub struct GlobalConfig { /// Configuration for measurements normalization. #[serde(skip_serializing_if = "Option::is_none")] @@ -106,7 +105,6 @@ fn is_err_or_empty(filters_config: &ErrorBoundary) -> bool /// All options passed down from Sentry to Relay. #[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(default)] -#[cfg_attr(feature = "jsonschema", derive(JsonSchema))] pub struct Options { /// List of platform names for which we allow using unsampled profiles for the purpose /// of improving profile (function) metrics @@ -235,7 +233,6 @@ pub struct Options { /// Kill switch for controlling the cardinality limiter. #[derive(Default, Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] -#[cfg_attr(feature = "jsonschema", derive(JsonSchema))] pub enum CardinalityLimiterMode { /// Cardinality limiter is enabled. #[default] @@ -251,7 +248,6 @@ pub enum CardinalityLimiterMode { /// Configuration container to control [`BucketEncoding`] per namespace. #[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq)] -#[cfg_attr(feature = "jsonschema", derive(JsonSchema))] #[serde(default)] pub struct BucketEncodings { transactions: BucketEncoding, diff --git a/relay-event-normalization/Cargo.toml b/relay-event-normalization/Cargo.toml index 1ddf0c795d..4dc8f7e4d9 100644 --- a/relay-event-normalization/Cargo.toml +++ b/relay-event-normalization/Cargo.toml @@ -48,3 +48,4 @@ similar-asserts = { workspace = true } [features] default = ["mmap"] mmap = ["maxminddb/mmap"] +serde = [] diff --git a/relay-event-normalization/src/normalize/user_agent.rs b/relay-event-normalization/src/normalize/user_agent.rs index 9f28a99588..1f0cb5bb15 100644 --- a/relay-event-normalization/src/normalize/user_agent.rs +++ b/relay-event-normalization/src/normalize/user_agent.rs @@ -196,7 +196,6 @@ impl<'a> RawUserAgentInfo<&'a str> { /// /// See #[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ClientHints where S: Default + AsRef, diff --git a/relay-event-schema/src/protocol/debugmeta.rs b/relay-event-schema/src/protocol/debugmeta.rs index 6b5f08cbee..9b49aa2e0b 100644 --- a/relay-event-schema/src/protocol/debugmeta.rs +++ b/relay-event-schema/src/protocol/debugmeta.rs @@ -337,7 +337,7 @@ pub struct NativeDebugImage { /// Unique debug identifier of the image. /// /// - `elf`: Debug identifier of the dynamic library or executable. If a code identifier is available, the debug identifier is the little-endian UUID representation of the first 16-bytes of that - /// identifier. Spaces are inserted for readability, note the byte order of the first fields: + /// identifier. Spaces are inserted for readability, note the byte order of the first fields: /// /// ```text /// code id: f1c3bcc0 2798 65fe 3058 404b2831d9e6 4135386c @@ -371,7 +371,7 @@ pub struct NativeDebugImage { /// The optional checksum of the debug companion file. /// /// - `pe_dotnet`: This is the hash algorithm and hex-formatted checksum of the associated PDB file. - /// This should have the format `$algorithm:$hash`, for example `SHA256:aabbccddeeff...`. + /// This should have the format `$algorithm:$hash`, for example `SHA256:aabbccddeeff...`. /// /// See: pub debug_checksum: Annotated, diff --git a/relay-filter/src/config.rs b/relay-filter/src/config.rs index 1ea40b4497..281a3eb9f5 100644 --- a/relay-filter/src/config.rs +++ b/relay-filter/src/config.rs @@ -272,19 +272,19 @@ impl GenericFilterConfig { /// configs yielding the filters according to the principles below: /// /// - Filters from project configs are evaluated before filters from global -/// configs. +/// configs. /// - No duplicates: once a filter is evaluated (yielded or skipped), no filter -/// with the same id is evaluated again. +/// with the same id is evaluated again. /// - Filters in project configs override filters from global configs, but the -/// opposite is never the case. +/// opposite is never the case. /// - A filter in the project config can be a flag, where only `is_enabled` is -/// defined and `condition` is not. In that case: +/// defined and `condition` is not. In that case: /// - If `is_enabled` is true, the filter with a matching ID from global -/// configs is yielded without evaluating its `is_enabled`. Unless the filter -/// in the global config also has an empty condition, in which case the filter -/// is not yielded. +/// configs is yielded without evaluating its `is_enabled`. Unless the filter +/// in the global config also has an empty condition, in which case the filter +/// is not yielded. /// - If `is_enabled` is false, no filters with the same IDs are returned, -/// including matching filters from global configs. +/// including matching filters from global configs. /// /// # Examples /// diff --git a/relay-filter/src/generic.rs b/relay-filter/src/generic.rs index c5b3eb0642..f0840ccf31 100644 --- a/relay-filter/src/generic.rs +++ b/relay-filter/src/generic.rs @@ -67,12 +67,12 @@ pub(crate) fn should_filter( /// If filters are compatible, an iterator over all filters is returned. This /// iterator yields filters according to the principles below: /// - Filters from project configs are evaluated before filters from global -/// configs. +/// configs. /// - No duplicates: once a filter is evaluated (yielded or skipped), no filter -/// with the same id is evaluated again. +/// with the same id is evaluated again. /// - If a filter with the same id exists in projects and global configs, both -/// are merged and the filter is yielded. Values from the filter in the project -/// config are prioritized. +/// are merged and the filter is yielded. Values from the filter in the project +/// config are prioritized. fn merge_generic_filters<'a>( project: &'a GenericFiltersConfig, global: Option<&'a GenericFiltersConfig>, diff --git a/relay-server/src/extractors/forwarded_for.rs b/relay-server/src/extractors/forwarded_for.rs index d571368ea2..0817cb2fc7 100644 --- a/relay-server/src/extractors/forwarded_for.rs +++ b/relay-server/src/extractors/forwarded_for.rs @@ -37,7 +37,7 @@ impl ForwardedFor { /// /// First match wins in order: /// - [`Self::CLOUDFLARE_FORWARDED_HEADER`], highest priority since users may use Cloudflare - /// infront of Vercel, it is generally the first layer. + /// infront of Vercel, it is generally the first layer. /// - [`Self::VERCEL_FORWARDED_HEADER`] /// - [`Self::SENTRY_FORWARDED_HEADER`] /// - [`Self::FORWARDED_HEADER`]. diff --git a/relay-server/src/services/global_config.rs b/relay-server/src/services/global_config.rs index bc08352626..4f438967a6 100644 --- a/relay-server/src/services/global_config.rs +++ b/relay-server/src/services/global_config.rs @@ -301,7 +301,7 @@ impl GlobalConfigService { /// This function checks two levels of results: /// 1. Whether the request to the upstream was successful. /// 2. If the request was successful, it then checks whether the returned - /// global config is valid and contains the expected data. + /// global config is valid and contains the expected data. fn handle_result(&mut self, result: UpstreamQueryResult) { match result { Ok(Ok(response)) => { diff --git a/relay-server/src/services/project_cache.rs b/relay-server/src/services/project_cache.rs index dd7440dece..2b28a878ef 100644 --- a/relay-server/src/services/project_cache.rs +++ b/relay-server/src/services/project_cache.rs @@ -148,7 +148,7 @@ impl CheckEnvelope { /// next stage: /// /// - If the envelope needs dynamic sampling, and the project state is not cached or out of the -/// date, the envelopes is spooled and we continue when the state is fetched. +/// date, the envelopes is spooled and we continue when the state is fetched. /// - Otherwise, the envelope is directly submitted to the [`EnvelopeProcessor`]. /// /// [`EnvelopeProcessor`]: crate::services::processor::EnvelopeProcessor @@ -840,9 +840,9 @@ impl ProjectCacheBroker { /// /// Few conditions are checked here: /// - If there is no dynamic sampling key and the project is already cached, we do straight to - /// processing otherwise buffer the envelopes. + /// processing otherwise buffer the envelopes. /// - If the dynamic sampling key is provided and if the root and sampling projects - /// are cached - process the envelope, buffer otherwise. + /// are cached - process the envelope, buffer otherwise. /// /// This means if the caches are hot we always process all the incoming envelopes without any /// delay. But in case the project state cannot be fetched, we keep buffering till the state diff --git a/relay-server/src/statsd.rs b/relay-server/src/statsd.rs index ba6cb2ece5..0629ac9d47 100644 --- a/relay-server/src/statsd.rs +++ b/relay-server/src/statsd.rs @@ -683,9 +683,9 @@ pub enum RelayCounters { /// - `has_parent` (only for event_type span): `false` if the span is the root of a trace. /// - `platform` (only for event_type span): The platform from which the span was spent. /// - `metric_type` (only for event_type metric): The metric type, counter, distribution, - /// gauge or set. + /// gauge or set. /// - `metric_encoding` (only for event_type metric): The encoding used for distribution and - /// set metrics. + /// set metrics. /// /// The message types can be: /// diff --git a/relay-server/tests/snapshots/test_fixtures__event_schema.snap b/relay-server/tests/snapshots/test_fixtures__event_schema.snap index ad6afa474f..c6c6a88c9b 100644 --- a/relay-server/tests/snapshots/test_fixtures__event_schema.snap +++ b/relay-server/tests/snapshots/test_fixtures__event_schema.snap @@ -2569,7 +2569,7 @@ expression: "relay_event_schema::protocol::event_json_schema()" ] }, "debug_checksum": { - "description": " The optional checksum of the debug companion file.\n\n - `pe_dotnet`: This is the hash algorithm and hex-formatted checksum of the associated PDB file.\n This should have the format `$algorithm:$hash`, for example `SHA256:aabbccddeeff...`.\n\n See: ", + "description": " The optional checksum of the debug companion file.\n\n - `pe_dotnet`: This is the hash algorithm and hex-formatted checksum of the associated PDB file.\n This should have the format `$algorithm:$hash`, for example `SHA256:aabbccddeeff...`.\n\n See: ", "default": null, "type": [ "string", @@ -2589,7 +2589,7 @@ expression: "relay_event_schema::protocol::event_json_schema()" ] }, "debug_id": { - "description": " Unique debug identifier of the image.\n\n - `elf`: Debug identifier of the dynamic library or executable. If a code identifier is available, the debug identifier is the little-endian UUID representation of the first 16-bytes of that\n identifier. Spaces are inserted for readability, note the byte order of the first fields:\n\n ```text\n code id: f1c3bcc0 2798 65fe 3058 404b2831d9e6 4135386c\n debug id: c0bcc3f1-9827-fe65-3058-404b2831d9e6\n ```\n\n If no code id is available, the debug id should be computed by XORing the first 4096 bytes of the `.text` section in 16-byte chunks, and representing it as a little-endian UUID (again swapping the byte order).\n\n - `pe`: `signature` and `age` of the PDB file. Both values can be read from the CodeView PDB70 debug information header in the PE. The value should be represented as little-endian UUID, with the age appended at the end. Note that the byte order of the UUID fields must be swapped (spaces inserted for readability):\n\n ```text\n signature: f1c3bcc0 2798 65fe 3058 404b2831d9e6\n age: 1\n debug_id: c0bcc3f1-9827-fe65-3058-404b2831d9e6-1\n ```\n\n - `macho`: Identifier of the dynamic library or executable. It is the value of the `LC_UUID` load command in the Mach header, formatted as UUID.", + "description": " Unique debug identifier of the image.\n\n - `elf`: Debug identifier of the dynamic library or executable. If a code identifier is available, the debug identifier is the little-endian UUID representation of the first 16-bytes of that\n identifier. Spaces are inserted for readability, note the byte order of the first fields:\n\n ```text\n code id: f1c3bcc0 2798 65fe 3058 404b2831d9e6 4135386c\n debug id: c0bcc3f1-9827-fe65-3058-404b2831d9e6\n ```\n\n If no code id is available, the debug id should be computed by XORing the first 4096 bytes of the `.text` section in 16-byte chunks, and representing it as a little-endian UUID (again swapping the byte order).\n\n - `pe`: `signature` and `age` of the PDB file. Both values can be read from the CodeView PDB70 debug information header in the PE. The value should be represented as little-endian UUID, with the age appended at the end. Note that the byte order of the UUID fields must be swapped (spaces inserted for readability):\n\n ```text\n signature: f1c3bcc0 2798 65fe 3058 404b2831d9e6\n age: 1\n debug_id: c0bcc3f1-9827-fe65-3058-404b2831d9e6-1\n ```\n\n - `macho`: Identifier of the dynamic library or executable. It is the value of the `LC_UUID` load command in the Mach header, formatted as UUID.", "anyOf": [ { "$ref": "#/definitions/DebugId"