From b380532d283fa5deebfedc86c3ffa7fb7cc76acf Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:58:19 +0100 Subject: [PATCH 1/4] ref(config): Add links to docs in YAML config file --- relay-config/src/config.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/relay-config/src/config.rs b/relay-config/src/config.rs index 2b0aee78152..bde52e4366b 100644 --- a/relay-config/src/config.rs +++ b/relay-config/src/config.rs @@ -193,8 +193,20 @@ trait ConfigObject: DeserializeOwned + Serialize { .with_context(|| ConfigError::file(ConfigErrorKind::CouldNotWriteFile, &path))?; match Self::format() { - ConfigFormat::Yaml => serde_yaml::to_writer(&mut f, self) - .with_context(|| ConfigError::file(ConfigErrorKind::CouldNotWriteFile, &path))?, + ConfigFormat::Yaml => { + f.write_all(b"# Please see the relevant documentation:\n") + .unwrap(); + f.write_all( + b"# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/\n" + ) + .unwrap(); + f.write_all( + b"# All config options: https://docs.sentry.io/product/relay/options/\n", + ) + .unwrap(); + serde_yaml::to_writer(&mut f, self) + .with_context(|| ConfigError::file(ConfigErrorKind::CouldNotWriteFile, &path))? + } ConfigFormat::Json => serde_json::to_writer_pretty(&mut f, self) .with_context(|| ConfigError::file(ConfigErrorKind::CouldNotWriteFile, &path))?, } From 4d49d1df769ed67833d87f87b639d1720329c18b Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:01:11 +0100 Subject: [PATCH 2/4] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7fb456a49d..0882eac4d0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ - Synthesize new class attribute in device context using specs found on the device, such as processor_count, memory_size, etc. ([#1895](https://github.com/getsentry/relay/pull/1895)) - Add `thread.state` field to protocol. ([#1896](https://github.com/getsentry/relay/pull/1896)) - Optionally mark scrubbed URL transactions as sanitized. ([#1917](https://github.com/getsentry/relay/pull/1917)) -- Perform PII scrubbing on meta's original_value field ([#1892](https://github.com/getsentry/relay/pull/1892)) +- Perform PII scrubbing on meta's original_value field. ([#1892](https://github.com/getsentry/relay/pull/1892)) +- Add links to docs in YAML config file. ([#1923](https://github.com/getsentry/relay/pull/1923)) **Bug Fixes**: From 348dece234459d5fbf914398677487aab0af91cb Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:23:21 +0100 Subject: [PATCH 3/4] Extract strings as `const &str` --- relay-config/src/config.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/relay-config/src/config.rs b/relay-config/src/config.rs index bde52e4366b..ad417966e27 100644 --- a/relay-config/src/config.rs +++ b/relay-config/src/config.rs @@ -24,6 +24,11 @@ use crate::upstream::UpstreamDescriptor; const DEFAULT_NETWORK_OUTAGE_GRACE_PERIOD: u64 = 10; +static CONFIG_YAML_HEADER: &str = r###"# Please see the relevant documentation. +# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ +# All config options: https://docs.sentry.io/product/relay/options/ +"###; + /// Indicates config related errors. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[non_exhaustive] @@ -194,16 +199,7 @@ trait ConfigObject: DeserializeOwned + Serialize { match Self::format() { ConfigFormat::Yaml => { - f.write_all(b"# Please see the relevant documentation:\n") - .unwrap(); - f.write_all( - b"# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/\n" - ) - .unwrap(); - f.write_all( - b"# All config options: https://docs.sentry.io/product/relay/options/\n", - ) - .unwrap(); + f.write_all(CONFIG_HEADER.as_bytes())?; serde_yaml::to_writer(&mut f, self) .with_context(|| ConfigError::file(ConfigErrorKind::CouldNotWriteFile, &path))? } From 83f8480c6d3dc556cf3d9233729f1dabbffec063 Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:33:59 +0100 Subject: [PATCH 4/4] Fix varname --- relay-config/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-config/src/config.rs b/relay-config/src/config.rs index ad417966e27..9682f3a1f52 100644 --- a/relay-config/src/config.rs +++ b/relay-config/src/config.rs @@ -199,7 +199,7 @@ trait ConfigObject: DeserializeOwned + Serialize { match Self::format() { ConfigFormat::Yaml => { - f.write_all(CONFIG_HEADER.as_bytes())?; + f.write_all(CONFIG_YAML_HEADER.as_bytes())?; serde_yaml::to_writer(&mut f, self) .with_context(|| ConfigError::file(ConfigErrorKind::CouldNotWriteFile, &path))? }