diff options
author | Brian Chen <brianc118@fb.com> | 2022-04-18 13:53:48 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2022-04-18 13:53:48 -0700 |
commit | c4ea2995b0f01d81057ca1ffc23118b5f5829d16 (patch) | |
tree | 805c61efaf7af2531483ef24fb0a7f289194d577 | |
parent | 4b05b09ac757021a5e8d68945e62c543f2eb18fb (diff) |
Move field_ids.rs
Reviewed By: dschatzberg
Differential Revision: D35557841
fbshipit-source-id: 8c52a68676881f1fcacd24a8a541d2a591455c33
-rw-r--r-- | below/model/src/common_field_ids.rs (renamed from below/model/src/field_ids.rs) | 4 | ||||
-rw-r--r-- | below/model/src/lib.rs | 15 | ||||
-rw-r--r-- | below/model/src/open_source/field_ids.rs | 26 | ||||
-rw-r--r-- | below/model/src/open_source/mod.rs | 16 |
4 files changed, 55 insertions, 6 deletions
diff --git a/below/model/src/field_ids.rs b/below/model/src/common_field_ids.rs index c1a91588..32f6dc28 100644 --- a/below/model/src/field_ids.rs +++ b/below/model/src/common_field_ids.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -/// All available field id representations of the base `Model` struct. +/// Common available field id representations of the base `Model` struct. /// /// Most can be parsed as `ModelFieldId` and used to query a Model. Some are /// parameterized field ids (with angle bracketed variable like <idx>) that must @@ -23,7 +23,7 @@ /// /// This list also servers as documentation for available field ids that could /// be used in other below crates. A test ensures that this list is up-to-date. -pub const MODEL_FIELD_IDS: &[&'static str] = &[ +pub const COMMON_MODEL_FIELD_IDS: &[&str] = &[ "system.hostname", "system.kernel_version", "system.os_release", diff --git a/below/model/src/lib.rs b/below/model/src/lib.rs index b616d056..0bd4caf4 100644 --- a/below/model/src/lib.rs +++ b/below/model/src/lib.rs @@ -25,7 +25,7 @@ pub mod collector; pub mod cgroup; pub mod collector_plugin; #[cfg(test)] -mod field_ids; +mod common_field_ids; pub mod network; pub mod process; pub mod sample; @@ -36,6 +36,10 @@ pub mod system; pub mod facebook; #[cfg(fbcode_build)] pub use facebook::*; +#[cfg(not(fbcode_build))] +pub mod open_source; +#[cfg(not(fbcode_build))] +pub use open_source::*; pub use cgroup::*; pub use collector::*; @@ -440,11 +444,14 @@ mod tests { #[test] fn test_model_field_ids() { - // Ensure MODEL_FIELD_IDS is update to date. - let all_variants = ModelFieldId::all_variant_iter() + // Ensure COMMON_MODEL_FIELD_IDS is update to date. + let mut all_variants = ModelFieldId::all_variant_iter() .map(|v| v.to_string()) .collect::<Vec<_>>(); - assert_eq!(all_variants, field_ids::MODEL_FIELD_IDS); + all_variants.sort_unstable(); + let mut expected_field_ids = field_ids::MODEL_FIELD_IDS.to_vec(); + expected_field_ids.sort_unstable(); + assert_eq!(all_variants, expected_field_ids); } #[test] diff --git a/below/model/src/open_source/field_ids.rs b/below/model/src/open_source/field_ids.rs new file mode 100644 index 00000000..f6fb9c15 --- /dev/null +++ b/below/model/src/open_source/field_ids.rs @@ -0,0 +1,26 @@ +// Copyright (c) Facebook, Inc. and its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// All available field id representations of the base `Model` struct. +/// +/// Most can be parsed as `ModelFieldId` and used to query a Model. Some are +/// parameterized field ids (with angle bracketed variable like <idx>) that must +/// have the variable substituted with specific values to be parsed correctly. +/// +/// For example, <idx> must be some zero-indexed Vec index, <cgroup_path> must +/// be a path and <key> could be pid, disk name, iface name etc. +/// +/// This list also servers as documentation for available field ids that could +/// be used in other below crates. A test ensures that this list is up-to-date. +pub const MODEL_FIELD_IDS: &[&str] = crate::common_field_ids::COMMON_MODEL_FIELD_IDS; diff --git a/below/model/src/open_source/mod.rs b/below/model/src/open_source/mod.rs new file mode 100644 index 00000000..d0d7e16c --- /dev/null +++ b/below/model/src/open_source/mod.rs @@ -0,0 +1,16 @@ +// Copyright (c) Facebook, Inc. and its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[cfg(test)] +pub mod field_ids; |