Skip to content

Commit 4c5ebaf

Browse files
authored
Merge branch 'dev-v3.x' into zach/router-1910
2 parents 1bd61ca + 2b5c2b6 commit 4c5ebaf

43 files changed

Lines changed: 2723 additions & 456 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### Remove the deprecated `connectors.subgraphs` configuration field
2+
3+
The deprecated `connectors.subgraphs` configuration field has been removed. The replacement `connectors.sources` field has been available since 2.x with a deprecation warning.
4+
5+
Existing configurations are migrated automatically at startup: each `subgraphs.<subgraph_name>.sources.<source_name>` entry is collapsed into a single `sources` entry keyed by `<subgraph_name>.<source_name>`, and any `$config` block at the subgraph level is copied onto each source. The router logs a notice describing the rewrite.
6+
7+
The migration preserves the deprecated runtime's precedence rules, including when a `connectors.sources` entry already exists for the same `<subgraph>.<source>` key: the deprecated `override_url` / `max_requests_per_operation` win over it when set, and a subgraph-level `$config` always overwrites any source-level `$config` — matching the order in which the old `apply_config` applied the two shapes.
8+
9+
Two cases can't be fully replicated automatically, and the router logs a separate notice for them:
10+
11+
- A subgraph entry that only declares `$config` (no `sources`) can't be expressed in the new shape, since `$config` is per-source there; its `$config` is dropped.
12+
- The deprecated runtime applied a subgraph's `$config` to *every* connector under that subgraph, including ones on `@source`s the deprecated config's own `sources` map didn't list. The migration can only copy `$config` onto the composite keys it can see, so if your schema declares additional sources for a migrated subgraph, copy `$config` onto their `connectors.sources` entries by hand.
13+
14+
Before:
15+
16+
```yaml
17+
connectors:
18+
subgraphs:
19+
my_subgraph:
20+
$config:
21+
api_key: "secret"
22+
sources:
23+
my_source:
24+
override_url: https://example.com
25+
max_requests_per_operation: 50
26+
```
27+
28+
After (equivalent shape, produced automatically):
29+
30+
```yaml
31+
connectors:
32+
sources:
33+
my_subgraph.my_source:
34+
$config:
35+
api_key: "secret"
36+
override_url: https://example.com
37+
max_requests_per_operation: 50
38+
```
39+
40+
By [@BobaFetters](https://github.com/BobaFetters) in https://github.com/apollographql/router/pull/9520
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### Reduce the volume of traces sent to Apollo
2+
3+
The Router now caps the volume of traces it exports to Apollo (GraphOS) with a throttle that runs after the configured trace samplers. This helps to avoid the processing and transfer of traces that would be dropped by GraphOS at ingestion time anyway. A new option, `telemetry.apollo.tracing.throttle`, selects the strategy:
4+
5+
- `representative_traces` (default): Sends at most one representative trace per minute for each distinct combination of operation, client, latency bucket, error status, and operation type. Duplicate traces that share a combination already seen in the current minute are dropped. Error traces are retained at a higher rate. This mirrors the representative-trace filtering used by Apollo's engine reports pipeline.
6+
- `rate_limited`: Sends every trace but caps the export rate at a fixed maximum of 100 traces per second per Router instance. This is cheaper in CPU and memory than `representative_traces`. The rate is not configurable.
7+
8+
This throttle applies only to the trace pipeline that exports to Apollo Studio, and only to whatever the existing head samplers (`telemetry.apollo.sampler` and `telemetry.exporters.tracing.common.sampler`) already let through — it can only further reduce that traffic. Traces exported to a customer's own OTLP collector or to Datadog are unaffected. The existing `telemetry.apollo.sampler` continues to work as before, and to disable Apollo trace export entirely, set it to `always_off`.
9+
10+
Independently of the throttle, the Router now also always drops any individual trace larger than 10MB before exporting it to Apollo, since GraphOS rejects oversized traces at ingestion anyway. This limit is fixed and not configurable.
11+
12+
By [@bonnici](https://github.com/bonnici) in https://github.com/apollographql/router/pull/9848

‎apollo-router/src/configuration/metrics.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ impl InstrumentData {
423423
"$.tracing.batch_processor.max_export_timeout",
424424
opt.tracing.batch_processor.max_queue_size,
425425
"$.tracing.batch_processor.max_queue_size",
426+
opt.tracing.throttle,
427+
"$.tracing.throttle",
426428
opt.metrics.otlp.batch_processor.scheduled_delay,
427429
"$.metrics.otlp.batch_processor.scheduled_delay",
428430
opt.metrics.otlp.batch_processor.max_export_timeout,
@@ -447,12 +449,12 @@ impl InstrumentData {
447449
"$[?(@.expose_sources_in_context == true)]",
448450
opt.max_requests_per_operation_per_source,
449451
"$[?(@.max_requests_per_operation_per_source)]",
450-
opt.subgraph.config,
451-
"$[?(@.subgraphs..['$config'])]",
452+
opt.source.config,
453+
"$[?(@.sources..['$config'])]",
452454
opt.source.override_url,
453-
"$[?(@.subgraphs..sources..override_url)]",
455+
"$[?(@.sources..override_url)]",
454456
opt.source.max_requests_per_operation,
455-
"$[?(@.subgraphs..sources..max_requests_per_operation)]"
457+
"$[?(@.sources..max_requests_per_operation)]"
456458
);
457459

458460
populate_config_instrument!(

‎apollo-router/src/configuration/migrations/0036-preview_connectors_subgraphs.yaml‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎apollo-router/src/configuration/snapshots/apollo_router__configuration__metrics__test__metrics@apollo_telemetry.router.yaml.snap‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ expression: "& metrics.non_zero()"
2121
opt.tracing.batch_processor.max_export_timeout: 30s
2222
opt.tracing.batch_processor.max_queue_size: 2048
2323
opt.tracing.batch_processor.scheduled_delay: 5s
24+
opt.tracing.throttle: rate_limited
2425
- name: apollo.router.config.experimental_local_field_metrics
2526
data:
2627
datapoints:
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: apollo-router/src/configuration/metrics.rs
3-
expression: "&metrics.non_zero()"
3+
expression: "& metrics.non_zero()"
44
---
55
- name: apollo.router.config.connectors
66
data:
@@ -10,6 +10,6 @@ expression: "&metrics.non_zero()"
1010
opt.debug_extensions: true
1111
opt.expose_sources_in_context: true
1212
opt.max_requests_per_operation_per_source: true
13+
opt.source.config: true
1314
opt.source.max_requests_per_operation: true
1415
opt.source.override_url: true
15-
opt.subgraph.config: true

‎apollo-router/src/configuration/snapshots/apollo_router__configuration__metrics__test__metrics@experimental_features.router.yaml.snap‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ expression: "& metrics.non_zero()"
2121
opt.tracing.batch_processor.max_export_timeout: false
2222
opt.tracing.batch_processor.max_queue_size: false
2323
opt.tracing.batch_processor.scheduled_delay: false
24+
opt.tracing.throttle: false
2425
- name: apollo.router.config.experimental_chaos
2526
data:
2627
datapoints:

‎apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap‎

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ expression: "&schema"
277277
"type": "null"
278278
}
279279
],
280-
"description": "Per-exporter sampler for traces sent to Apollo Studio.\n\nUses the same trace-ID-based algorithm as `telemetry.exporters.tracing.common.sampler`.\nAccepts a decimal between 0.0 and 1.0, `always_on`, or `always_off`.\nShould be ≤ the common sampler; setting it higher has no effect.\n\nWhen `parent_based_sampler` is enabled (the default), traces arriving with a `traceparent`\nheader already marked as sampled by the calling service will be passed through to this\nexporter regardless of this sampler's value — including when set to `always_off`."
280+
"description": "Per-exporter sampler for traces sent to Apollo Studio.\n\nUses the same trace-ID-based algorithm as `telemetry.exporters.tracing.common.sampler`.\nAccepts a decimal between 0.0 and 1.0, `always_on`, or `always_off`.\nShould be ≤ the common sampler; setting it higher has no effect.\n\nWhen `parent_based_sampler` is enabled (the default), traces arriving with a `traceparent`\nheader already marked as sampled by the calling service will be passed through to this\nexporter regardless of this sampler's value — including when set to `always_off`.\n\nWhatever this sampler lets through is then subject to `tracing.throttle`, which acts as a\nback-stop that further reduces trace volume sent to Apollo Studio."
281281
},
282282
"send_headers": {
283283
"allOf": [
@@ -320,6 +320,21 @@ expression: "&schema"
320320
},
321321
"type": "object"
322322
},
323+
"ApolloTraceThrottleConfig": {
324+
"description": "The back-stop strategy used to throttle the volume of traces exported to Apollo Studio, after\nhead sampling.",
325+
"oneOf": [
326+
{
327+
"const": "representative_traces",
328+
"description": "Send at most one representative trace per minute for each distinct combination of dimensions\n(operation, client, latency bucket, error status, operation type). Duplicate traces sharing\na combination already seen within the current minute are dropped. These traces would end up\nbeing dropped by Apollo at ingestion time anyway.",
329+
"type": "string"
330+
},
331+
{
332+
"const": "rate_limited",
333+
"description": "Send every trace, but cap the export rate at a fixed maximum of 100 traces per second (per\nrouter instance). Cheaper than `representative_traces` in CPU and memory, at the cost of a\nless even sample. The rate is not configurable.",
334+
"type": "string"
335+
}
336+
]
337+
},
323338
"ApolloUsageReportsBatchProcessorConfiguration": {
324339
"properties": {
325340
"max_export_timeout": {
@@ -2973,15 +2988,6 @@ expression: "&schema"
29732988
"default": {},
29742989
"description": "Map of subgraph_name.connector_source_name to source configuration",
29752990
"type": "object"
2976-
},
2977-
"subgraphs": {
2978-
"additionalProperties": {
2979-
"$ref": "#/definitions/SubgraphConnectorConfiguration"
2980-
},
2981-
"default": {},
2982-
"deprecated": true,
2983-
"description": "A map of subgraph name to connectors config for that subgraph",
2984-
"type": "object"
29852991
}
29862992
},
29872993
"type": "object"
@@ -10268,27 +10274,6 @@ expression: "&schema"
1026810274
}
1026910275
]
1027010276
},
10271-
"SubgraphConnectorConfiguration": {
10272-
"additionalProperties": false,
10273-
"description": "Configuration for a connector subgraph",
10274-
"properties": {
10275-
"$config": {
10276-
"additionalProperties": true,
10277-
"default": {},
10278-
"description": "Other values that can be used by connectors via `{$config.<key>}`",
10279-
"type": "object"
10280-
},
10281-
"sources": {
10282-
"additionalProperties": {
10283-
"$ref": "#/definitions/SourceConfiguration"
10284-
},
10285-
"default": {},
10286-
"description": "A map of `@source(name:)` to configuration for that source",
10287-
"type": "object"
10288-
}
10289-
},
10290-
"type": "object"
10291-
},
1029210277
"SubgraphDeduplicationConfigConfiguration": {
1029310278
"description": "Configuration options pertaining to the subgraph server component.",
1029410279
"properties": {
@@ -12638,6 +12623,14 @@ expression: "&schema"
1263812623
}
1263912624
],
1264012625
"description": "Configuration for tracing batch processor."
12626+
},
12627+
"throttle": {
12628+
"allOf": [
12629+
{
12630+
"$ref": "#/definitions/ApolloTraceThrottleConfig"
12631+
}
12632+
],
12633+
"description": "Back-stop that throttles the volume of traces sent to Apollo Studio, applied *after* the\n`telemetry.apollo.sampler` and `telemetry.exporters.tracing.common.sampler` head samplers."
1264112634
}
1264212635
},
1264312636
"type": "object"

‎apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__upgrade_old_configuration@connectors_preview.router.yaml.snap‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ connectors:
77
debug_extensions: true
88
expose_sources_in_context: true
99
max_requests_per_operation_per_source: 50
10-
subgraphs:
11-
subgraph_name:
12-
sources:
13-
source_name:
14-
override_url: "http://localhost:5280"
10+
sources:
11+
subgraph_name.source_name:
12+
override_url: "http://localhost:5280"
13+
max_requests_per_operation: 50
14+
$config:
15+
api_key: secret
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
source: apollo-router/src/configuration/upgrade.rs
3+
expression: config
4+
---
5+
{
6+
"connectors": {
7+
"sources": {
8+
"sub_a.src_1": {
9+
"override_url": "http://one",
10+
"$config": {
11+
"api_key": "secret"
12+
}
13+
},
14+
"sub_a.src_2": {
15+
"override_url": "http://two",
16+
"max_requests_per_operation": 5,
17+
"$config": {
18+
"api_key": "secret"
19+
}
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)