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

Mostly fix json schema generation for otel config. #607

Merged
merged 4 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
use a layer vs a plugin. As the layer API is a subset of the plugin API the layer option has been removed.
## 🚀 Features
## 🐛 Fixes
- **Reporting plugin schema generation** ([PR #607](https://github.com/apollographql/router/pull/607))
Previously our reporting plugin configuration did not participate in json schema generation. This is now broadly correct
and make writing schema much easier.

To generate a schema use the following command.
```
router --schema > apollo_configuration_schema.json
```
and follow the instructions for associating it with your particular text editor/IDE.
## 🛠 Maintenance
## 📚 Documentation

Expand Down
4 changes: 2 additions & 2 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub(crate) fn default_service_namespace() -> String {
"apollo".to_string()
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
pub enum Secret {
Env(String),
Expand All @@ -292,7 +292,7 @@ impl Secret {
}
}

#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[derive(Debug, Clone, Default, Deserialize, Serialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct TlsConfig {
domain_name: Option<String>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: apollo-router/src/configuration/mod.rs
assertion_line: 355
assertion_line: 357
expression: "&schema"

---
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
Expand Down Expand Up @@ -126,6 +125,58 @@ expression: "&schema"
},
"additionalProperties": false
},
"Exporter": {
"oneOf": [
{
"type": "object",
"required": [
"grpc"
],
"properties": {
"grpc": {
"$ref": "#/definitions/GrpcExporter",
"nullable": true
}
},
"additionalProperties": false
}
]
},
"GrpcExporter": {
"type": "object",
"required": [
"protocol"
],
"properties": {
"endpoint": {
"default": null,
"type": "string",
"format": "uri",
"nullable": true
},
"metadata": {
"default": null,
"type": "object",
"additionalProperties": true,
"nullable": true
},
"protocol": {
"$ref": "#/definitions/ProtocolMirror",
"nullable": true
},
"timeout": {
"type": "integer",
"format": "uint64",
"minimum": 0.0,
"nullable": true
},
"tls_config": {
"$ref": "#/definitions/TlsConfig",
"nullable": true
}
},
"additionalProperties": false
},
"Insert": {
"type": "object",
"required": [
Expand All @@ -142,6 +193,53 @@ expression: "&schema"
},
"additionalProperties": false
},
"Jaeger": {
"type": "object",
"properties": {
"endpoint": {
"$ref": "#/definitions/JaegerEndpoint",
"nullable": true
},
"service_name": {
"default": "router",
"type": "string"
},
"trace_config": {
"$ref": "#/definitions/TraceConfig",
"nullable": true
}
},
"additionalProperties": false
},
"JaegerEndpoint": {
"oneOf": [
{
"type": "object",
"required": [
"agent"
],
"properties": {
"agent": {
"type": "string"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"collector"
],
"properties": {
"collector": {
"type": "string",
"format": "uri"
}
},
"additionalProperties": false
}
]
},
"ListenAddr": {
"description": "Listening address.",
"anyOf": [
Expand All @@ -156,7 +254,33 @@ expression: "&schema"
]
},
"OpenTelemetry": {
"$ref": "#/definitions/OpenTelemetry"
"oneOf": [
{
"type": "object",
"required": [
"jaeger"
],
"properties": {
"jaeger": {
"$ref": "#/definitions/Jaeger",
"nullable": true
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"otlp"
],
"properties": {
"otlp": {
"$ref": "#/definitions/Otlp"
}
},
"additionalProperties": false
}
]
},
"OpenTracingConfig": {
"type": "object",
Expand Down Expand Up @@ -209,6 +333,23 @@ expression: "&schema"
}
]
},
"Otlp": {
"oneOf": [
{
"type": "object",
"required": [
"tracing"
],
"properties": {
"tracing": {
"$ref": "#/definitions/Tracing",
"nullable": true
}
},
"additionalProperties": false
}
]
},
"Plugins": {
"anyOf": [
{
Expand Down Expand Up @@ -328,6 +469,13 @@ expression: "&schema"
"zipkin_b3"
]
},
"ProtocolMirror": {
"type": "string",
"enum": [
"Grpc",
"HttpBinary"
]
},
"Remove": {
"oneOf": [
{
Expand Down Expand Up @@ -356,6 +504,59 @@ expression: "&schema"
}
]
},
"SamplerMirror": {
"oneOf": [
{
"type": "string",
"enum": [
"AlwaysOn",
"AlwaysOff"
]
},
{
"description": "Respects the parent span's sampling decision or delegates a delegate sampler for root spans. Not supported via yaml config Sample a given fraction of traces. Fractions >= 1 will always sample. If the parent span is sampled, then it's child spans will automatically be sampled. Fractions < 0 are treated as zero, but spans may still be sampled if their parent is.",
"type": "object",
"required": [
"TraceIdRatioBased"
],
"properties": {
"TraceIdRatioBased": {
"type": "number",
"format": "double"
}
},
"additionalProperties": false
}
]
},
"Secret": {
"oneOf": [
{
"type": "object",
"required": [
"env"
],
"properties": {
"env": {
"type": "string"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string"
}
},
"additionalProperties": false
}
]
},
"Server": {
"description": "Configuration options pertaining to the http server component.",
"type": "object",
Expand Down Expand Up @@ -396,6 +597,93 @@ expression: "&schema"
},
"StudioGraph": {
"type": "object"
},
"TlsConfig": {
"type": "object",
"properties": {
"ca": {
"$ref": "#/definitions/Secret",
"nullable": true
},
"cert": {
"$ref": "#/definitions/Secret",
"nullable": true
},
"domain_name": {
"type": "string",
"nullable": true
},
"key": {
"$ref": "#/definitions/Secret",
"nullable": true
}
},
"additionalProperties": false
},
"TraceConfig": {
"type": "object",
"required": [
"resource",
"sampler"
],
"properties": {
"max_attributes_per_event": {
"type": "integer",
"format": "uint32",
"minimum": 0.0,
"nullable": true
},
"max_attributes_per_link": {
"type": "integer",
"format": "uint32",
"minimum": 0.0,
"nullable": true
},
"max_attributes_per_span": {
"type": "integer",
"format": "uint32",
"minimum": 0.0,
"nullable": true
},
"max_events_per_span": {
"type": "integer",
"format": "uint32",
"minimum": 0.0,
"nullable": true
},
"max_links_per_span": {
"type": "integer",
"format": "uint32",
"minimum": 0.0,
"nullable": true
},
"resource": {
"type": "object",
"additionalProperties": true,
"nullable": true
},
"sampler": {
"$ref": "#/definitions/SamplerMirror",
"nullable": true
}
},
"additionalProperties": false
},
"Tracing": {
"type": "object",
"required": [
"exporter"
],
"properties": {
"exporter": {
"$ref": "#/definitions/Exporter"
},
"trace_config": {
"$ref": "#/definitions/TraceConfig",
"nullable": true
}
},
"additionalProperties": false
}
}
}
Loading