Skip to content
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 8 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
Having plugins and layers as configurable items in yaml was creating confusion as to when it was appropriate to
use a layer vs a plugin. As the layer API is a subset of the plugin API the layer option has been removed.

- **Move Apollo plugins to top level configuration**
- **Move Apollo plugins to top level configuration** ([PR #623](https://github.com/apollographql/router/pull/623))
Previously plugins were all under the `plugins:` section of the yaml config. However, now apollo plugins are promoted
to the top level of the config. This reflects the fact that these plugins provide core functionality even though they
are implemented as plugins under the hood.

- **Reporting config name changed to telemetry** ([PR #651](https://github.com/apollographql/router/pull/651))
All configuration that was previously under the `reporting` header is now under `telemetry`

## 🚀 Features

- **Add Rhai plugin** ([PR #548](https://github.com/apollographql/router/pull/484))
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ requires that the `federation-demo` project is running:
Once the subgraphs are up and running, run Apollo Router with this command:

```shell
cargo run --release -- -s ./examples/graphql/local.graphql -c examples/config/config-jaeger.yml
cargo run --release -- -s ./examples/graphql/local.graphql -c examples/telemetry/jaeger.router.yaml
```

Go to https://studio.apollographql.com/sandbox/explorer to make queries and
Expand Down
34 changes: 10 additions & 24 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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,
});
Expand All @@ -131,26 +133,10 @@ impl FromStr for Configuration {
}

fn gen_schema(plugins: schemars::Map<String, Schema>) -> Schema {
let plugins_refs = plugins
Copy link
Contributor Author

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.

.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))),
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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()
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 443
assertion_line: 439
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 444
assertion_line: 440
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 445
assertion_line: 441
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 442
assertion_line: 438
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 471
assertion_line: 467
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 470
assertion_line: 466
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: apollo-router/src/configuration/mod.rs
assertion_line: 488
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 487
assertion_line: 473
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 484
assertion_line: 480
expression: config
---
plugins: {}
plugins: ~
server:
listen: "1.2.3.4:5"
cors: ~
Expand Down
Loading