-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename reporting plugin to telemetry #651
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c3d7683
Rename reporting plugin to telemetry
510c61c
Changelog
16e17a9
Fix schema generation.
6f3ffda
Make plugins optional.
074cbff
Fix tests
5d56725
Fix tests
9acb869
Update examples and readme
2692eaf
rename spaceport file
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ use derivative::Derivative; | |
use displaydoc::Display; | ||
use itertools::Itertools; | ||
use schemars::gen::SchemaGenerator; | ||
use schemars::schema::{ObjectValidation, Schema, SchemaObject, SubschemaValidation}; | ||
use schemars::{JsonSchema, Set}; | ||
use schemars::schema::{ObjectValidation, Schema, SchemaObject}; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::Map; | ||
use serde_json::Value; | ||
|
@@ -88,7 +88,7 @@ impl Configuration { | |
if is_global_subscriber_set() { | ||
// Add the reporting plugin, this will be overridden if such a plugin actually exists in the config. | ||
// Note that this can only be done if the global subscriber has been set, i.e. we're not unit testing. | ||
plugins.push(("apollo.reporting".into(), Value::Object(Map::new()))); | ||
plugins.push(("apollo.telemetry".into(), Value::Object(Map::new()))); | ||
} | ||
|
||
// Add all the apollo plugins | ||
|
@@ -100,13 +100,15 @@ impl Configuration { | |
} | ||
|
||
// Add all the user plugins | ||
for (plugin, config) in &self.plugins.plugins { | ||
plugins.push((plugin.clone(), config.clone())); | ||
if let Some(config_map) = self.plugins.plugins.as_ref() { | ||
for (plugin, config) in config_map { | ||
plugins.push((plugin.clone(), config.clone())); | ||
} | ||
} | ||
|
||
// Plugins must be sorted. For now this sort is hard coded, but we may add something generic. | ||
plugins.sort_by_key(|(name, _)| match name.as_str() { | ||
"apollo.reporting" => -100, | ||
"apollo.telemetry" => -100, | ||
"apollo.rhai" => 100, | ||
_ => 0, | ||
}); | ||
|
@@ -131,26 +133,10 @@ impl FromStr for Configuration { | |
} | ||
|
||
fn gen_schema(plugins: schemars::Map<String, Schema>) -> Schema { | ||
let plugins_refs = plugins | ||
.keys() | ||
.map(|name| { | ||
Schema::Object(SchemaObject { | ||
object: Some(Box::new(ObjectValidation { | ||
required: Set::from([name.to_string()]), | ||
..Default::default() | ||
})), | ||
..Default::default() | ||
}) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
let plugins_object = SchemaObject { | ||
object: Some(Box::new(ObjectValidation { | ||
properties: plugins, | ||
..Default::default() | ||
})), | ||
subschemas: Some(Box::new(SubschemaValidation { | ||
any_of: Some(plugins_refs), | ||
additional_properties: Option::Some(Box::new(Schema::Bool(false))), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do however want to prevent random new properties being added. |
||
..Default::default() | ||
})), | ||
..Default::default() | ||
|
@@ -192,7 +178,7 @@ impl JsonSchema for ApolloPlugins { | |
#[derive(Clone, Debug, Default, Deserialize, Serialize, TypedBuilder)] | ||
#[serde(transparent)] | ||
pub struct UserPlugins { | ||
pub plugins: Map<String, Value>, | ||
pub plugins: Option<Map<String, Value>>, | ||
} | ||
|
||
impl JsonSchema for UserPlugins { | ||
|
4 changes: 2 additions & 2 deletions
4
...hots/apollo_router__configuration__tests__ensure_configuration_api_does_not_change-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...hots/apollo_router__configuration__tests__ensure_configuration_api_does_not_change-3.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...hots/apollo_router__configuration__tests__ensure_configuration_api_does_not_change-4.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...pshots/apollo_router__configuration__tests__ensure_configuration_api_does_not_change.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...apollo_router__configuration__tests__ensure_configuration_api_does_not_change_grpc-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...s/apollo_router__configuration__tests__ensure_configuration_api_does_not_change_grpc.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...s/apollo_router__configuration__tests__ensure_configuration_api_does_not_change_http.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...lo_router__configuration__tests__ensure_configuration_api_does_not_change_tls_config.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is no longer needed because we switched to incline schemas.