diff --git a/.changesets/config_bryn_telemetry_enabled_field.md b/.changesets/config_bryn_telemetry_enabled_field.md new file mode 100644 index 0000000000..2fc3d75996 --- /dev/null +++ b/.changesets/config_bryn_telemetry_enabled_field.md @@ -0,0 +1,20 @@ +### Add `enabled` field for telemetry exporters ([PR #3952](https://github.com/apollographql/router/pull/3952)) + +Telemetry configuration now supports `enabled` on all exporters. This allows exporters to be disabled without removing them from the configuration and in addition allows for a more streamlined default configuration. + +```diff +telemetry: + tracing: + datadog: ++ enabled: true + jaeger: ++ enabled: true + otlp: ++ enabled: true + zipkin: ++ enabled: true +``` + +Existing configurations will be migrated to the new format automatically on startup. However, you should update your configuration to use the new format as soon as possible. + +By [@BrynCooke](https://github.com/BrynCooke) in https://github.com/apollographql/router/pull/3952 diff --git a/apollo-router/src/configuration/metrics.rs b/apollo-router/src/configuration/metrics.rs index a19ac6a192..2d9439e9d8 100644 --- a/apollo-router/src/configuration/metrics.rs +++ b/apollo-router/src/configuration/metrics.rs @@ -305,13 +305,13 @@ impl Metrics { opt.metrics.prometheus, "$.metrics.prometheus[?(@.enabled==true)]", opt.tracing.otlp, - "$.tracing.otlp[?(@.endpoint)]", + "$.tracing.otlp[?(@.enabled==true)]", opt.tracing.datadog, - "$.tracing.datadog[?(@.endpoint)]", + "$.tracing.datadog[?(@.enabled==true)]", opt.tracing.jaeger, - "$.tracing.jaeger[?(@..endpoint)]", + "$.tracing.jaeger[?(@.enabled==true)]", opt.tracing.zipkin, - "$.tracing.zipkin[?(@.endpoint)]" + "$.tracing.zipkin[?(@.enabled==true)]" ); log_usage_metrics!( value.apollo.router.config.batching, diff --git a/apollo-router/src/configuration/migrations/0012-telemetry-exporters-enabled.yaml b/apollo-router/src/configuration/migrations/0012-telemetry-exporters-enabled.yaml new file mode 100644 index 0000000000..606a63551e --- /dev/null +++ b/apollo-router/src/configuration/migrations/0012-telemetry-exporters-enabled.yaml @@ -0,0 +1,22 @@ +description: Telemetry exporters now have an enabled field +actions: + - type: add + path: telemetry.tracing.jaeger + name: enabled + value: true + - type: add + path: telemetry.tracing.otlp + name: enabled + value: true + - type: add + path: telemetry.tracing.zipkin + name: enabled + value: true + - type: add + path: telemetry.tracing.datadog + name: enabled + value: true + - type: add + path: telemetry.metrics.otlp + name: enabled + value: true diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap index b6abe5209a..b0f6bdc380 100644 --- a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap @@ -2073,19 +2073,6 @@ expression: "&schema" "properties": { "batch_processor": { "description": "Configuration for batch processing.", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -4501,24 +4488,11 @@ expression: "&schema" "description": "Open Telemetry native exporter configuration", "type": "object", "required": [ - "endpoint" + "enabled" ], "properties": { "batch_processor": { "description": "Batch processor settings", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -4560,6 +4534,10 @@ expression: "&schema" } } }, + "enabled": { + "description": "Enable otlp", + "type": "boolean" + }, "endpoint": { "description": "The endpoint to send data to", "type": "string" @@ -4705,24 +4683,11 @@ expression: "&schema" "description": "Datadog exporter configuration", "type": "object", "required": [ - "endpoint" + "enabled" ], "properties": { "batch_processor": { "description": "batch processor configuration", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -4769,6 +4734,10 @@ expression: "&schema" "default": false, "type": "boolean" }, + "enabled": { + "description": "Enable datadog", + "type": "boolean" + }, "endpoint": { "description": "The endpoint to send to", "type": "string" @@ -4800,15 +4769,12 @@ expression: "&schema" { "type": "object", "required": [ - "agent" + "enabled" ], "properties": { "agent": { "description": "Agent configuration", "type": "object", - "required": [ - "endpoint" - ], "properties": { "endpoint": { "description": "The endpoint to send to", @@ -4819,19 +4785,6 @@ expression: "&schema" }, "batch_processor": { "description": "Batch processor configuration", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -4872,6 +4825,10 @@ expression: "&schema" "type": "string" } } + }, + "enabled": { + "description": "Enable Jaeger", + "type": "boolean" } }, "additionalProperties": false @@ -4879,24 +4836,11 @@ expression: "&schema" { "type": "object", "required": [ - "collector" + "enabled" ], "properties": { "batch_processor": { "description": "Batch processor configuration", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -4941,9 +4885,6 @@ expression: "&schema" "collector": { "description": "Collector configuration", "type": "object", - "required": [ - "endpoint" - ], "properties": { "endpoint": { "description": "The endpoint to send reports to", @@ -4951,16 +4892,22 @@ expression: "&schema" }, "password": { "description": "The optional password", + "default": null, "type": "string", "nullable": true }, "username": { "description": "The optional username", + "default": null, "type": "string", "nullable": true } }, "additionalProperties": false + }, + "enabled": { + "description": "Enable Jaeger", + "type": "boolean" } }, "additionalProperties": false @@ -4972,24 +4919,11 @@ expression: "&schema" "description": "OpenTelemetry native exporter configuration", "type": "object", "required": [ - "endpoint" + "enabled" ], "properties": { "batch_processor": { "description": "Batch processor settings", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -5031,6 +4965,10 @@ expression: "&schema" } } }, + "enabled": { + "description": "Enable otlp", + "type": "boolean" + }, "endpoint": { "description": "The endpoint to send data to", "type": "string" @@ -5334,24 +5272,11 @@ expression: "&schema" "description": "Zipkin exporter configuration", "type": "object", "required": [ - "endpoint" + "enabled" ], "properties": { "batch_processor": { "description": "Batch processor configuration", - "default": { - "scheduled_delay": { - "secs": 5, - "nanos": 0 - }, - "max_queue_size": 2048, - "max_export_batch_size": 512, - "max_export_timeout": { - "secs": 30, - "nanos": 0 - }, - "max_concurrent_exports": 1 - }, "type": "object", "properties": { "max_concurrent_exports": { @@ -5393,6 +5318,10 @@ expression: "&schema" } } }, + "enabled": { + "description": "Enable zipkin", + "type": "boolean" + }, "endpoint": { "description": "The endpoint to send to", "type": "string" diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@datadog_enabled.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@datadog_enabled.router.yaml.snap new file mode 100644 index 0000000000..cf57ddc55d --- /dev/null +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@datadog_enabled.router.yaml.snap @@ -0,0 +1,11 @@ +--- +source: apollo-router/src/configuration/tests.rs +expression: new_config +--- +--- +telemetry: + tracing: + datadog: + endpoint: default + enabled: true + diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_enabled.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_enabled.router.yaml.snap new file mode 100644 index 0000000000..dba3e1b0de --- /dev/null +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_enabled.router.yaml.snap @@ -0,0 +1,12 @@ +--- +source: apollo-router/src/configuration/tests.rs +expression: new_config +--- +--- +telemetry: + tracing: + jaeger: + agent: + endpoint: default + enabled: true + diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_scheduled_delay.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_scheduled_delay.router.yaml.snap index 3007513330..8314e7726f 100644 --- a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_scheduled_delay.router.yaml.snap +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@jaeger_scheduled_delay.router.yaml.snap @@ -10,4 +10,5 @@ telemetry: endpoint: default batch_processor: scheduled_delay: 100ms + enabled: true diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@otlp_enabled.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@otlp_enabled.router.yaml.snap new file mode 100644 index 0000000000..49626d1c7a --- /dev/null +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@otlp_enabled.router.yaml.snap @@ -0,0 +1,15 @@ +--- +source: apollo-router/src/configuration/tests.rs +expression: new_config +--- +--- +telemetry: + tracing: + otlp: + endpoint: default + enabled: true + metrics: + otlp: + endpoint: default + enabled: true + diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@telemetry_otlp_timeout.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@telemetry_otlp_timeout.router.yaml.snap index 204b8d07a1..7be72dfa1a 100644 --- a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@telemetry_otlp_timeout.router.yaml.snap +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@telemetry_otlp_timeout.router.yaml.snap @@ -9,4 +9,5 @@ telemetry: endpoint: default batch_processor: max_export_timeout: 5s + enabled: true diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@zipkin_enabled.router.yaml.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@zipkin_enabled.router.yaml.snap new file mode 100644 index 0000000000..d5adad9806 --- /dev/null +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@zipkin_enabled.router.yaml.snap @@ -0,0 +1,11 @@ +--- +source: apollo-router/src/configuration/tests.rs +expression: new_config +--- +--- +telemetry: + tracing: + zipkin: + endpoint: default + enabled: true + diff --git a/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml b/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml index 794cd985cb..373b08465c 100644 --- a/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml +++ b/apollo-router/src/configuration/testdata/metrics/telemetry.router.yaml @@ -3,15 +3,20 @@ telemetry: prometheus: enabled: true otlp: + enabled: true endpoint: default tracing: otlp: + enabled: true endpoint: default zipkin: + enabled: true endpoint: default datadog: + enabled: true endpoint: default jaeger: + enabled: true agent: endpoint: default diff --git a/apollo-router/src/configuration/testdata/migrations/datadog_enabled.router.yaml b/apollo-router/src/configuration/testdata/migrations/datadog_enabled.router.yaml new file mode 100644 index 0000000000..0c947de9a9 --- /dev/null +++ b/apollo-router/src/configuration/testdata/migrations/datadog_enabled.router.yaml @@ -0,0 +1,4 @@ +telemetry: + tracing: + datadog: + endpoint: default diff --git a/apollo-router/src/configuration/testdata/migrations/jaeger_enabled.router.yaml b/apollo-router/src/configuration/testdata/migrations/jaeger_enabled.router.yaml new file mode 100644 index 0000000000..a38bb8d5e6 --- /dev/null +++ b/apollo-router/src/configuration/testdata/migrations/jaeger_enabled.router.yaml @@ -0,0 +1,5 @@ +telemetry: + tracing: + jaeger: + agent: + endpoint: default diff --git a/apollo-router/src/configuration/testdata/migrations/otlp_enabled.router.yaml b/apollo-router/src/configuration/testdata/migrations/otlp_enabled.router.yaml new file mode 100644 index 0000000000..a015f0aafc --- /dev/null +++ b/apollo-router/src/configuration/testdata/migrations/otlp_enabled.router.yaml @@ -0,0 +1,7 @@ +telemetry: + tracing: + otlp: + endpoint: default + metrics: + otlp: + endpoint: default diff --git a/apollo-router/src/configuration/testdata/migrations/zipkin_enabled.router.yaml b/apollo-router/src/configuration/testdata/migrations/zipkin_enabled.router.yaml new file mode 100644 index 0000000000..567ac42fa8 --- /dev/null +++ b/apollo-router/src/configuration/testdata/migrations/zipkin_enabled.router.yaml @@ -0,0 +1,4 @@ +telemetry: + tracing: + zipkin: + endpoint: default diff --git a/apollo-router/src/configuration/testdata/tracing_datadog.router.yaml b/apollo-router/src/configuration/testdata/tracing_datadog.router.yaml index e557b3d4db..ac73a3c751 100644 --- a/apollo-router/src/configuration/testdata/tracing_datadog.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_datadog.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: datadog: + enabled: true endpoint: default diff --git a/apollo-router/src/configuration/testdata/tracing_datadog_env.router.yaml b/apollo-router/src/configuration/testdata/tracing_datadog_env.router.yaml index 5f9c360e19..8836bb1c7e 100644 --- a/apollo-router/src/configuration/testdata/tracing_datadog_env.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_datadog_env.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: datadog: + enabled: true endpoint: ${env.TEST_CONFIG_ENDPOINT} diff --git a/apollo-router/src/configuration/testdata/tracing_jaeger_agent.router.yaml b/apollo-router/src/configuration/testdata/tracing_jaeger_agent.router.yaml index de854410b1..2db3814d2a 100644 --- a/apollo-router/src/configuration/testdata/tracing_jaeger_agent.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_jaeger_agent.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: jaeger: + enabled: true agent: endpoint: default diff --git a/apollo-router/src/configuration/testdata/tracing_jaeger_collector.router.yaml b/apollo-router/src/configuration/testdata/tracing_jaeger_collector.router.yaml index f1c9631995..7689f1bc75 100644 --- a/apollo-router/src/configuration/testdata/tracing_jaeger_collector.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_jaeger_collector.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: jaeger: + enabled: true collector: endpoint: http://example.com diff --git a/apollo-router/src/configuration/testdata/tracing_jaeger_collector_env.router.yaml b/apollo-router/src/configuration/testdata/tracing_jaeger_collector_env.router.yaml index b97eef76a7..f42008f5bb 100644 --- a/apollo-router/src/configuration/testdata/tracing_jaeger_collector_env.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_jaeger_collector_env.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: jaeger: + enabled: true collector: endpoint: ${env.TEST_CONFIG_COLLECTOR_ENDPOINT} diff --git a/apollo-router/src/configuration/testdata/tracing_jaeger_full.router.yaml b/apollo-router/src/configuration/testdata/tracing_jaeger_full.router.yaml index 51c3461cd1..f4fb38d8ef 100644 --- a/apollo-router/src/configuration/testdata/tracing_jaeger_full.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_jaeger_full.router.yaml @@ -3,6 +3,7 @@ supergraph: telemetry: tracing: jaeger: + enabled: true collector: endpoint: "http://foo" password: "" diff --git a/apollo-router/src/configuration/testdata/tracing_otlp_full.router.yaml b/apollo-router/src/configuration/testdata/tracing_otlp_full.router.yaml index ce67ceddbd..2d6e2b38d9 100644 --- a/apollo-router/src/configuration/testdata/tracing_otlp_full.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_otlp_full.router.yaml @@ -3,6 +3,7 @@ supergraph: telemetry: tracing: otlp: + enabled: true endpoint: default grpc: ca: "" diff --git a/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic.router.yaml b/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic.router.yaml index b4e4c9faf2..3ae1254643 100644 --- a/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: otlp: + enabled: true endpoint: default protocol: http diff --git a/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic_env.router.yaml b/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic_env.router.yaml index 98ddf29dd7..5b16c52cbb 100644 --- a/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic_env.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_otlp_grpc_basic_env.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: otlp: + enabled: true endpoint: ${env.TEST_CONFIG_ENDPOINT} protocol: http diff --git a/apollo-router/src/configuration/testdata/tracing_otlp_http_basic.router.yaml b/apollo-router/src/configuration/testdata/tracing_otlp_http_basic.router.yaml index b4e4c9faf2..3ae1254643 100644 --- a/apollo-router/src/configuration/testdata/tracing_otlp_http_basic.router.yaml +++ b/apollo-router/src/configuration/testdata/tracing_otlp_http_basic.router.yaml @@ -3,5 +3,6 @@ supergraph: telemetry: tracing: otlp: + enabled: true endpoint: default protocol: http diff --git a/apollo-router/src/configuration/testdata/zipkin-address.router.yaml b/apollo-router/src/configuration/testdata/zipkin-address.router.yaml index 84113a8e6d..3f8e0d60e2 100644 --- a/apollo-router/src/configuration/testdata/zipkin-address.router.yaml +++ b/apollo-router/src/configuration/testdata/zipkin-address.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: zipkin:9411 diff --git a/apollo-router/src/configuration/testdata/zipkin-url.router.yaml b/apollo-router/src/configuration/testdata/zipkin-url.router.yaml index 0872c59ee5..d756550677 100644 --- a/apollo-router/src/configuration/testdata/zipkin-url.router.yaml +++ b/apollo-router/src/configuration/testdata/zipkin-url.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: http://zipkin:9411/api/v2/spans diff --git a/apollo-router/src/configuration/testdata/zipkin-url_env.router.yaml b/apollo-router/src/configuration/testdata/zipkin-url_env.router.yaml index e1c97281b0..548cdef2b7 100644 --- a/apollo-router/src/configuration/testdata/zipkin-url_env.router.yaml +++ b/apollo-router/src/configuration/testdata/zipkin-url_env.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: ${env.TEST_CONFIG_ENDPOINT} diff --git a/apollo-router/src/configuration/testdata/zipkin.router.yaml b/apollo-router/src/configuration/testdata/zipkin.router.yaml index 90cef738c6..b042bd602e 100644 --- a/apollo-router/src/configuration/testdata/zipkin.router.yaml +++ b/apollo-router/src/configuration/testdata/zipkin.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: default diff --git a/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap b/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap index ce01b7cc2f..602557c5a1 100644 --- a/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap +++ b/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__create_report.snap @@ -21,6 +21,7 @@ usage: configuration.override_subgraph_url.len: 1 configuration.plugins.len: 0 configuration.telemetry.apollo.send_headers.len: 1 + configuration.telemetry.tracing.otlp.enabled.true: 1 configuration.telemetry.tracing.otlp.endpoint.: 1 configuration.telemetry.tracing.otlp.grpc.metadata.len: 2 configuration.telemetry.tracing.otlp.protocol.: 1 diff --git a/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__visit_config.snap b/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__visit_config.snap index e375b378de..6bdf13c507 100644 --- a/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__visit_config.snap +++ b/apollo-router/src/orbiter/snapshots/apollo_router__orbiter__test__visit_config.snap @@ -14,6 +14,7 @@ configuration.headers.subgraphs..request.remove.len: 1 configuration.headers.subgraphs..request.remove.named.: 1 configuration.override_subgraph_url.len: 1 configuration.telemetry.apollo.send_headers.len: 1 +configuration.telemetry.tracing.otlp.enabled.true: 1 configuration.telemetry.tracing.otlp.endpoint.: 1 configuration.telemetry.tracing.otlp.grpc.metadata.len: 2 configuration.telemetry.tracing.otlp.protocol.: 1 diff --git a/apollo-router/src/orbiter/testdata/redaction.router.yaml b/apollo-router/src/orbiter/testdata/redaction.router.yaml index 6a2554c096..96a752fdf3 100644 --- a/apollo-router/src/orbiter/testdata/redaction.router.yaml +++ b/apollo-router/src/orbiter/testdata/redaction.router.yaml @@ -25,6 +25,7 @@ telemetry: - "bar" tracing: otlp: + enabled: true protocol: grpc endpoint: default grpc: diff --git a/apollo-router/src/plugins/telemetry/metrics/otlp.rs b/apollo-router/src/plugins/telemetry/metrics/otlp.rs index d38d91ad0e..c152e1e97a 100644 --- a/apollo-router/src/plugins/telemetry/metrics/otlp.rs +++ b/apollo-router/src/plugins/telemetry/metrics/otlp.rs @@ -38,7 +38,9 @@ impl MetricsConfigurator for super::super::otlp::Config { metrics_config: &MetricsCommon, ) -> Result { let exporter: MetricExporterBuilder = self.exporter()?; - + if !self.enabled { + return Ok(builder); + } match exporter.exporter { Some(exporter) => { let exporter = MetricsExporterBuilder::Tonic(exporter).build_metrics_exporter( diff --git a/apollo-router/src/plugins/telemetry/otlp.rs b/apollo-router/src/plugins/telemetry/otlp.rs index 144d11efa5..254be94887 100644 --- a/apollo-router/src/plugins/telemetry/otlp.rs +++ b/apollo-router/src/plugins/telemetry/otlp.rs @@ -30,10 +30,14 @@ lazy_static! { static ref DEFAULT_HTTP_ENDPOINT: Uri = Uri::from_static("http://127.0.0.1:4318"); } -#[derive(Debug, Clone, Deserialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, JsonSchema, Default)] #[serde(deny_unknown_fields)] pub(crate) struct Config { + /// Enable otlp + pub(crate) enabled: bool, + /// The endpoint to send data to + #[serde(default)] pub(crate) endpoint: UriEndpoint, /// The protocol to use when sending data diff --git a/apollo-router/src/plugins/telemetry/tracing/datadog.rs b/apollo-router/src/plugins/telemetry/tracing/datadog.rs index 4dd6b59370..5b951754de 100644 --- a/apollo-router/src/plugins/telemetry/tracing/datadog.rs +++ b/apollo-router/src/plugins/telemetry/tracing/datadog.rs @@ -35,10 +35,14 @@ lazy_static! { static ref DEFAULT_ENDPOINT: Uri = Uri::from_static("http://localhost:8126/v0.4/traces"); } -#[derive(Debug, Clone, Deserialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, JsonSchema, Default)] #[serde(deny_unknown_fields)] pub(crate) struct Config { + /// Enable datadog + pub(crate) enabled: bool, + /// The endpoint to send to + #[serde(default)] pub(crate) endpoint: UriEndpoint, /// batch processor configuration @@ -52,6 +56,9 @@ pub(crate) struct Config { impl TracingConfigurator for Config { fn apply(&self, builder: Builder, trace: &Trace) -> Result { + if !self.enabled { + return Ok(builder); + } tracing::info!("Configuring Datadog tracing: {}", self.batch_processor); let enable_span_mapping = self.enable_span_mapping.then_some(true); let trace_config: sdk::trace::Config = trace.into(); diff --git a/apollo-router/src/plugins/telemetry/tracing/jaeger.rs b/apollo-router/src/plugins/telemetry/tracing/jaeger.rs index 8fca71dd4f..5edd3394f6 100644 --- a/apollo-router/src/plugins/telemetry/tracing/jaeger.rs +++ b/apollo-router/src/plugins/telemetry/tracing/jaeger.rs @@ -19,13 +19,17 @@ use crate::plugins::telemetry::tracing::SpanProcessorExt; use crate::plugins::telemetry::tracing::TracingConfigurator; lazy_static! { - static ref DEFAULT_ENDPOINT: Uri = Uri::from_static("http://localhost:14268/api/traces"); + static ref DEFAULT_ENDPOINT: Uri = Uri::from_static("http://127.0.0.1:14268/api/traces"); } #[derive(Debug, Clone, Deserialize, JsonSchema)] #[serde(deny_unknown_fields, untagged)] pub(crate) enum Config { Agent { + /// Enable Jaeger + enabled: bool, + /// Agent configuration + #[serde(default)] agent: AgentConfig, /// Batch processor configuration @@ -33,7 +37,11 @@ pub(crate) enum Config { batch_processor: BatchProcessorConfig, }, Collector { + /// Enable Jaeger + enabled: bool, + /// Collector configuration + #[serde(default)] collector: CollectorConfig, /// Batch processor configuration @@ -42,15 +50,15 @@ pub(crate) enum Config { }, } -#[derive(Debug, Clone, Deserialize, JsonSchema)] -#[serde(deny_unknown_fields)] +#[derive(Debug, Clone, Deserialize, JsonSchema, Default)] +#[serde(deny_unknown_fields, default)] pub(crate) struct AgentConfig { /// The endpoint to send to endpoint: SocketEndpoint, } -#[derive(Debug, Clone, Deserialize, JsonSchema)] -#[serde(deny_unknown_fields)] +#[derive(Debug, Clone, Deserialize, JsonSchema, Default)] +#[serde(deny_unknown_fields, default)] pub(crate) struct CollectorConfig { /// The endpoint to send reports to endpoint: UriEndpoint, @@ -64,10 +72,11 @@ impl TracingConfigurator for Config { fn apply(&self, builder: Builder, trace_config: &Trace) -> Result { match &self { Config::Agent { + enabled, agent, batch_processor, - } => { - tracing::info!("Configuring Jaeger tracing: {}", batch_processor); + } if *enabled => { + tracing::info!("Configuring Jaeger tracing: {} (agent)", batch_processor); let exporter = opentelemetry_jaeger::new_agent_pipeline() .with_trace_config(trace_config.into()) .with_service_name(trace_config.service_name.clone()) @@ -81,10 +90,15 @@ impl TracingConfigurator for Config { )) } Config::Collector { + enabled, collector, batch_processor, - } => { - tracing::info!("Configuring Jaeger tracing: {}", batch_processor); + } if *enabled => { + tracing::info!( + "Configuring Jaeger tracing: {} (collector)", + batch_processor + ); + let exporter = opentelemetry_jaeger::new_collector_pipeline() .with_trace_config(trace_config.into()) .with_service_name(trace_config.service_name.clone()) @@ -107,6 +121,7 @@ impl TracingConfigurator for Config { .build(), )) } + _ => Ok(builder), } } } diff --git a/apollo-router/src/plugins/telemetry/tracing/mod.rs b/apollo-router/src/plugins/telemetry/tracing/mod.rs index 4f9ebd21a3..362d804c3e 100644 --- a/apollo-router/src/plugins/telemetry/tracing/mod.rs +++ b/apollo-router/src/plugins/telemetry/tracing/mod.rs @@ -13,7 +13,6 @@ use opentelemetry::Context; use opentelemetry::KeyValue; use schemars::JsonSchema; use serde::Deserialize; -use serde::Serialize; use tower::BoxError; use crate::plugins::telemetry::config::Trace; @@ -96,7 +95,7 @@ where } /// Batch processor configuration -#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, JsonSchema)] #[serde(default)] pub(crate) struct BatchProcessorConfig { #[serde(deserialize_with = "humantime_serde::deserialize")] diff --git a/apollo-router/src/plugins/telemetry/tracing/otlp.rs b/apollo-router/src/plugins/telemetry/tracing/otlp.rs index d1754f1d68..b535389eb3 100644 --- a/apollo-router/src/plugins/telemetry/tracing/otlp.rs +++ b/apollo-router/src/plugins/telemetry/tracing/otlp.rs @@ -12,6 +12,9 @@ use crate::plugins::telemetry::tracing::TracingConfigurator; impl TracingConfigurator for super::super::otlp::Config { fn apply(&self, builder: Builder, _trace_config: &Trace) -> Result { + if !self.enabled { + return Ok(builder); + } tracing::info!("Configuring Otlp tracing: {}", self.batch_processor); let exporter: SpanExporterBuilder = self.exporter()?; Ok(builder.with_span_processor( diff --git a/apollo-router/src/plugins/telemetry/tracing/zipkin.rs b/apollo-router/src/plugins/telemetry/tracing/zipkin.rs index 7d0b5a2a92..2248b8c274 100644 --- a/apollo-router/src/plugins/telemetry/tracing/zipkin.rs +++ b/apollo-router/src/plugins/telemetry/tracing/zipkin.rs @@ -15,13 +15,17 @@ use crate::plugins::telemetry::tracing::SpanProcessorExt; use crate::plugins::telemetry::tracing::TracingConfigurator; lazy_static! { - static ref DEFAULT_ENDPOINT: Uri = Uri::from_static("http://localhost:9411/api/v2/spans"); + static ref DEFAULT_ENDPOINT: Uri = Uri::from_static("http://127.0.0.1:9411/api/v2/spans"); } -#[derive(Debug, Clone, Deserialize, JsonSchema)] +#[derive(Debug, Clone, Deserialize, JsonSchema, Default)] #[serde(deny_unknown_fields)] pub(crate) struct Config { + /// Enable zipkin + pub(crate) enabled: bool, + /// The endpoint to send to + #[serde(default)] pub(crate) endpoint: UriEndpoint, /// Batch processor configuration @@ -31,6 +35,9 @@ pub(crate) struct Config { impl TracingConfigurator for Config { fn apply(&self, builder: Builder, trace_config: &Trace) -> Result { + if !self.enabled { + return Ok(builder); + } tracing::info!("configuring Zipkin tracing: {}", self.batch_processor); let exporter = opentelemetry_zipkin::new_pipeline() diff --git a/apollo-router/src/testdata/datadog.router.yaml b/apollo-router/src/testdata/datadog.router.yaml index 46c95a7cd7..26790f8d37 100644 --- a/apollo-router/src/testdata/datadog.router.yaml +++ b/apollo-router/src/testdata/datadog.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router datadog: - endpoint: default \ No newline at end of file + enabled: true + endpoint: default diff --git a/apollo-router/src/testdata/jaeger.router.yaml b/apollo-router/src/testdata/jaeger.router.yaml index 8a69a788ad..8fbdf4c7af 100644 --- a/apollo-router/src/testdata/jaeger.router.yaml +++ b/apollo-router/src/testdata/jaeger.router.yaml @@ -13,6 +13,7 @@ telemetry: trace_config: service_name: router jaeger: + enabled: true batch_processor: scheduled_delay: 100ms agent: @@ -30,4 +31,4 @@ telemetry: override_subgraph_url: products: http://localhost:4005 include_subgraph_errors: - all: true \ No newline at end of file + all: true diff --git a/apollo-router/src/testdata/otlp.router.yaml b/apollo-router/src/testdata/otlp.router.yaml index 93ef400426..3550c97644 100644 --- a/apollo-router/src/testdata/otlp.router.yaml +++ b/apollo-router/src/testdata/otlp.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router otlp: - endpoint: default \ No newline at end of file + enabled: true + endpoint: default diff --git a/apollo-router/src/testdata/zipkin.router.yaml b/apollo-router/src/testdata/zipkin.router.yaml index a745c863bf..b042bd602e 100644 --- a/apollo-router/src/testdata/zipkin.router.yaml +++ b/apollo-router/src/testdata/zipkin.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: - endpoint: default \ No newline at end of file + enabled: true + endpoint: default diff --git a/apollo-router/tests/fixtures/broken_plugin.router.yaml b/apollo-router/tests/fixtures/broken_plugin.router.yaml index 5053ba9f7a..784b4481b0 100644 --- a/apollo-router/tests/fixtures/broken_plugin.router.yaml +++ b/apollo-router/tests/fixtures/broken_plugin.router.yaml @@ -13,6 +13,7 @@ telemetry: trace_config: service_name: router jaeger: + enabled: true batch_processor: scheduled_delay: 100ms agent: diff --git a/apollo-router/tests/fixtures/datadog.router.yaml b/apollo-router/tests/fixtures/datadog.router.yaml index 46c95a7cd7..26790f8d37 100644 --- a/apollo-router/tests/fixtures/datadog.router.yaml +++ b/apollo-router/tests/fixtures/datadog.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router datadog: - endpoint: default \ No newline at end of file + enabled: true + endpoint: default diff --git a/apollo-router/tests/fixtures/jaeger-0.5-sample.router.yaml b/apollo-router/tests/fixtures/jaeger-0.5-sample.router.yaml index a5a11b2829..b7c7a0dfcd 100644 --- a/apollo-router/tests/fixtures/jaeger-0.5-sample.router.yaml +++ b/apollo-router/tests/fixtures/jaeger-0.5-sample.router.yaml @@ -9,6 +9,7 @@ telemetry: service_name: router sampler: 0.5 jaeger: + enabled: true batch_processor: scheduled_delay: 100ms agent: diff --git a/apollo-router/tests/fixtures/jaeger-no-sample.router.yaml b/apollo-router/tests/fixtures/jaeger-no-sample.router.yaml index 8cf7dc8eff..6ec3390e23 100644 --- a/apollo-router/tests/fixtures/jaeger-no-sample.router.yaml +++ b/apollo-router/tests/fixtures/jaeger-no-sample.router.yaml @@ -12,6 +12,7 @@ telemetry: service_name: router sampler: always_off jaeger: + enabled: true batch_processor: scheduled_delay: 100ms agent: @@ -29,4 +30,4 @@ telemetry: override_subgraph_url: products: http://localhost:4005 include_subgraph_errors: - all: true \ No newline at end of file + all: true diff --git a/apollo-router/tests/fixtures/jaeger.router.yaml b/apollo-router/tests/fixtures/jaeger.router.yaml index a4e4b8bb1e..e5ee9ba59e 100644 --- a/apollo-router/tests/fixtures/jaeger.router.yaml +++ b/apollo-router/tests/fixtures/jaeger.router.yaml @@ -9,6 +9,7 @@ telemetry: service_name: router sampler: always_on jaeger: + enabled: true batch_processor: scheduled_delay: 100ms agent: diff --git a/apollo-router/tests/fixtures/otlp.router.yaml b/apollo-router/tests/fixtures/otlp.router.yaml index 93ef400426..3550c97644 100644 --- a/apollo-router/tests/fixtures/otlp.router.yaml +++ b/apollo-router/tests/fixtures/otlp.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router otlp: - endpoint: default \ No newline at end of file + enabled: true + endpoint: default diff --git a/apollo-router/tests/fixtures/zipkin.router.yaml b/apollo-router/tests/fixtures/zipkin.router.yaml index a745c863bf..b042bd602e 100644 --- a/apollo-router/tests/fixtures/zipkin.router.yaml +++ b/apollo-router/tests/fixtures/zipkin.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: - endpoint: default \ No newline at end of file + enabled: true + endpoint: default diff --git a/dockerfiles/tracing/router/datadog.router.yaml b/dockerfiles/tracing/router/datadog.router.yaml index 64a8a81608..edaaaf6417 100644 --- a/dockerfiles/tracing/router/datadog.router.yaml +++ b/dockerfiles/tracing/router/datadog.router.yaml @@ -9,6 +9,7 @@ telemetry: trace_config: service_name: router datadog: + enabled: true endpoint: datadog-agent:8126 propagation: datadog: true diff --git a/dockerfiles/tracing/router/jaeger.router.yaml b/dockerfiles/tracing/router/jaeger.router.yaml index d73ddd7f50..8f2065830e 100644 --- a/dockerfiles/tracing/router/jaeger.router.yaml +++ b/dockerfiles/tracing/router/jaeger.router.yaml @@ -9,6 +9,7 @@ telemetry: trace_config: service_name: router jaeger: + enabled: true agent: endpoint: jaeger:6831 propagation: diff --git a/dockerfiles/tracing/router/zipkin.router.yaml b/dockerfiles/tracing/router/zipkin.router.yaml index 435b79d862..e76b3a134e 100644 --- a/dockerfiles/tracing/router/zipkin.router.yaml +++ b/dockerfiles/tracing/router/zipkin.router.yaml @@ -9,6 +9,7 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: http://zipkin:9411/api/v2/spans propagation: zipkin: true diff --git a/docs/source/configuration/metrics.mdx b/docs/source/configuration/metrics.mdx index e5e97fea04..b7c02db97e 100644 --- a/docs/source/configuration/metrics.mdx +++ b/docs/source/configuration/metrics.mdx @@ -141,7 +141,10 @@ You can send metrics to [OpenTelemetry Collector](https://opentelemetry.io/docs/ telemetry: metrics: otlp: - # Either 'default' or a URL + # Enable the OpenTelemetry exporter + enabled: true + + # Optional endpoint, either 'default' or a URL (Defaults to http://127.0.0.1:4317 for gRPC and http://127.0.0.1:4318 for HTTP) endpoint: default # Optional protocol. Only grpc is supported currently. diff --git a/docs/source/configuration/tracing.mdx b/docs/source/configuration/tracing.mdx index b433e138b2..0681c2298f 100644 --- a/docs/source/configuration/tracing.mdx +++ b/docs/source/configuration/tracing.mdx @@ -134,6 +134,7 @@ telemetry: tracing: # Datadog datadog: + enabled: true batch_processor: scheduled_delay: 100ms max_concurrent_exports: 1000 @@ -156,6 +157,7 @@ The Apollo Router can be configured to connect to either the default agent addre telemetry: tracing: datadog: + enabled: true # Either 'default' or a URL (example: 'http://127.0.0.1:8126') endpoint: default ``` @@ -168,6 +170,7 @@ To fix this, you can configure the Apollo Router to perform a mapping for the sp telemetry: tracing: datadog: + enabled: true endpoint: default enable_span_mapping: true ``` @@ -212,15 +215,19 @@ Instead when `enable_span_mapping` is set to `true` the following trace will be The Apollo Router can be configured to export tracing data to Jaeger either via an agent or http collector. +Unless explicitly configured to use a collector, Jaeger will use an agent by default. + ### Agent config ```yaml title="router.yaml" telemetry: tracing: jaeger: + enabled: true + # Optional agent configuration, agent: - # Either 'default' or a URL - endpoint: docker_jaeger:14268 + # Optional endpoint, either 'default' or a socket address (Defaults to 127.0.0.1:6831) + endpoint: docker_jaeger:14268 ``` ### Collector config @@ -231,8 +238,11 @@ If you're using Kubernetes, you can inject your secrets into configuration via e telemetry: tracing: jaeger: + enabled: true + # Optional collector configuration, collector: - endpoint: "http://my-jaeger-collector" + # Optional endpoint, either 'default' or a URL (Defaults to http://127.0.0.1:14268/api/traces) + endpoint: "http://my-jaeger-collector" username: "${env.JAEGER_USERNAME}" password: "${env.JAEGER_PASSWORD}" ``` @@ -247,7 +257,9 @@ If you find that the built-in telemetry features of the Apollo Router are missin telemetry: tracing: otlp: - # Either 'default' or a URL + enabled: true + + # Optional endpoint, either 'default' or a URL (Defaults to http://127.0.0.1:4317 for gRPC and http://127.0.0.1:4318 for HTTP) endpoint: default # Optional protocol (Defaults to grpc) @@ -278,6 +290,8 @@ The Apollo Router can be configured to export tracing data to either the default telemetry: tracing: zipkin: - # Either 'default' or a URL - endpoint: http://my_zipkin_collector.dev + enabled: true + + # Optional endpoint, either 'default' or a URL (Defaults to http://127.0.0.1:9411/api/v2/spans) + endpoint: http://my_zipkin_collector.dev ``` diff --git a/examples/telemetry/datadog.router.yaml b/examples/telemetry/datadog.router.yaml index 0e9e98346d..26790f8d37 100644 --- a/examples/telemetry/datadog.router.yaml +++ b/examples/telemetry/datadog.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router datadog: + enabled: true endpoint: default diff --git a/examples/telemetry/jaeger-agent.router.yaml b/examples/telemetry/jaeger-agent.router.yaml index 40f2155625..365ecb376a 100644 --- a/examples/telemetry/jaeger-agent.router.yaml +++ b/examples/telemetry/jaeger-agent.router.yaml @@ -3,5 +3,6 @@ telemetry: trace_config: service_name: router jaeger: + enabled: true agent: endpoint: default diff --git a/examples/telemetry/jaeger-collector.router.yaml b/examples/telemetry/jaeger-collector.router.yaml index 9eb68b0f42..a31a69b854 100644 --- a/examples/telemetry/jaeger-collector.router.yaml +++ b/examples/telemetry/jaeger-collector.router.yaml @@ -3,6 +3,7 @@ telemetry: trace_config: service_name: router jaeger: + enabled: true collector: endpoint: "https://example.com" username: "username" diff --git a/examples/telemetry/otlp.router.yaml b/examples/telemetry/otlp.router.yaml index cbfa7ad982..3550c97644 100644 --- a/examples/telemetry/otlp.router.yaml +++ b/examples/telemetry/otlp.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router otlp: + enabled: true endpoint: default diff --git a/examples/telemetry/zipkin-agent.router.yaml b/examples/telemetry/zipkin-agent.router.yaml index 90cef738c6..b042bd602e 100644 --- a/examples/telemetry/zipkin-agent.router.yaml +++ b/examples/telemetry/zipkin-agent.router.yaml @@ -3,4 +3,5 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: default diff --git a/examples/telemetry/zipkin-collector.router.yaml b/examples/telemetry/zipkin-collector.router.yaml index a921df06ba..7335367285 100644 --- a/examples/telemetry/zipkin-collector.router.yaml +++ b/examples/telemetry/zipkin-collector.router.yaml @@ -3,5 +3,6 @@ telemetry: trace_config: service_name: router zipkin: + enabled: true endpoint: "https://example.com"