๐ Features
Support for UUID and Unix timestamp functions in Rhai (PR #2617)
When building Rhai scripts, you'll often need to add headers that either uniquely identify a request, or append timestamp information for processing information later, such as crafting a trace header or otherwise.
While the default timestamp()
and similar functions (e.g. apollo_start
) can be used, they aren't able to be translated into an epoch.
This adds a uuid_v4()
and unix_now()
function to obtain a UUID and Unix timestamp, respectively.
Show option to "Include Cookies" in Sandbox
Adds default support when using the "Include Cookies" toggle in the Embedded Sandbox.
Add a metric to track the cache size (Issue #2522)
We've introduced a new apollo_router_cache_size
metric that reports the current size of in-memory caches. Like other metrics, it is available via OpenTelemetry Metrics including Prometheus scraping.
Add a rhai global variable resolver and populate it (Issue #2628)
Rhai scripts cannot access Rust global constants by default, making cross plugin communication via Context
difficult.
This change introduces a new global variable resolver populates with a Router
global constant. It currently has three members:
APOLLO_START
-> should be used in place ofapollo_start
APOLLO_SDL
-> should be used in place ofapollo_sdl
APOLLO_AUTHENTICATION_JWT_CLAIMS
You access a member of this variable as follows:
let my_var = Router.APOLLO_SDL;
We are removing the experimental APOLLO_AUTHENTICATION_JWT_CLAIMS
constant, but we will retain the existing non-experimental constants for purposes of backwards compatibility.
We recommend that you shift to the new global constants since we will remove the old ones in a major breaking change release in the future.
Activate TLS for Redis cluster connections (Issue #2332)
This adds support for TLS connections in Redis Cluster mode, by applying it when the URLs use the rediss
schema.
By @Geaal in #2605
Make terminationGracePeriodSeconds
property configurable in the Helm chart
The terminationGracePeriodSeconds
property is now configurable on the Deployment
object in the Helm chart.
This can be useful when adjusting the default timeout values for the Router, and should always be a value slightly bigger than the Router timeout in order to ensure no requests are closed prematurely on shutdown.
The Router timeout is configured via traffic_shaping
traffic_shaping:
router:
timeout: ...
๐ Fixes
Properly emit histograms metrics via OpenTelemetry (Issue #2393)
With the "inexpensive" metrics selector, histograms are only reported as gauges which caused them to be incorrectly interpreted when reaching Datadog
Revisit Open Telemetry integration (Issue #1812, Issue #2359, Issue #2338, Issue #2113, Issue #2113)
There were several issues with the existing OpenTelemetry integration in the Router which we are happy to have resolved with this re-factoring:
-
Metrics would stop working after a schema or config update.
-
Telemetry config could not be changed at runtime, instead requiring a full restart of the router.
-
Logging format would vary depending on where the log statement existed in the code.
-
On shutdown, the following message occurred frequently:
OpenTelemetry trace error occurred: cannot send span to the batch span processor because the channel is closed
-
And worst of all, it had a tendency to leak memory.
We have corrected these by re-visiting the way we integrate with OpenTelemetry and the supporting tracing packages. The new implementation brings our usage in line with new best-practices.
In addition, the testing coverage for telemetry in general has been significantly improved. For more details of what changed and why take a look at #2358.
By @BrynCooke and @Geal and @bnjjj in #2358
Metrics attributes allow value types as defined by OpenTelemetry (Issue #2510)
Metrics attributes in OpenTelemetry allow the following types:
string
string[]
float
float[]
int
int[]
bool
bool[]
However, our configuration only allowed strings. This has been fixed, and therefore it is now possible to use booleans via environment variable expansion as metrics attributes.
For example:
telemetry:
metrics:
prometheus:
enabled: true
common:
attributes:
supergraph:
static:
- name: "my_boolean"
value: ''
By @BrynCooke in #2616
Add missing status
attribute on some metrics (PR #2593)
When labeling metrics, the Router did not consistently add the status
attribute, resulting in an empty status
. You'll now have status="500"
for Router errors.
๐ Maintenance
Upgrade to Apollo Federation v2.3.2
This brings in a patch update to our Federation support, bringing it to v2.3.2.
CORS: Give a more meaningful message for users who misconfigured allow_any_origin
(PR #2634)
Allowing "any" origin in the router configuration can be done as follows:
cors:
allow_any_origin: true
However, some intuition and familiarity with the CORS specification might also lead someone to configure it as follows:
cors:
origins:
- "*"
Unfortunately, this won't work and the error message received when it was attempted was neither comprehensive nor actionable:
ERROR panicked at 'Wildcard origin (`*`) cannot be passed to `AllowOrigin::list`. Use `AllowOrigin::any()` instead'
This usability improvement adds helpful instructions to the error message, pointing you to the correct pattern for setting up this behavior in the router:
Invalid CORS configuration: use `allow_any_origin: true` to set `Access-Control-Allow-Origin: *`
By @o0Ignition0o in #2634
๐งช Experimental
Cleanup the error reporting in the experimental JWT authentication plugin (PR #2609)
Introduce a new AuthenticationError
enum to document and consolidate various JWT processing errors that may occur.