Skip to content

Commit

Permalink
ref(globconfig): Set empty global config (#2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
iker-barriocanal committed Aug 11, 2023
1 parent e835f4f commit fd955bc
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions relay-dynamic-config/src/global.rs
Original file line number Diff line number Diff line change
@@ -1,58 +1,9 @@
use relay_general::store::MeasurementsConfig;
use serde::{Deserialize, Serialize};

use crate::TaggingRule;

/// A dynamic configuration for all Relays passed down from Sentry.
///
/// Values shared across all projects may also be included here, to keep
/// [`ProjectConfig`](crate::ProjectConfig)s small.
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct GlobalConfig {
/// Project configuration for measurements.
#[serde(skip_serializing_if = "Option::is_none")]
measurements: Option<MeasurementsConfig>,
/// Project configuration for rules for applying metrics tags depending on
/// the event's content.
#[serde(skip_serializing_if = "Option::is_none")]
metric_conditional_tagging: Option<Vec<TaggingRule>>,
}

#[cfg(test)]
mod tests {
use crate::GlobalConfig;

#[test]
fn test_global_config_roundtrip() {
let json = r#"{
"measurements": {
"builtinMeasurements": [
{
"name": "plate.size",
"unit": "5"
}
],
"maxCustomMeasurements": 2
},
"metricConditionalTagging": [
{
"condition": {
"op": "gt",
"name": "food.deliciousness",
"value": 8
},
"targetMetrics": [
"tummy.satisfaction"
],
"targetTag": "satisfied",
"tagValue": "hellyeah"
}
]
}"#;

let deserialized: GlobalConfig = serde_json::from_str(json).unwrap();
let reserialized = serde_json::to_string_pretty(&deserialized).unwrap();
assert_eq!(json, reserialized);
}
}
pub struct GlobalConfig {}

0 comments on commit fd955bc

Please sign in to comment.