New Features
Server Timeouts
Baseplate.py servers will now time out requests that are taking too long. This is useful because often the upstream client has timed out already and the server is just wasting processing by continuing to work on the request. Timeouts are configurable as a cross-service default and per-endpoint.
**Note: all requests will now time out after a default 10 seconds. See the documentation to configure this for your service.**
[See the documentation for more information](https://baseplate.readthedocs.io/en/v1.2.0/api/baseplate/observers/timeout.html).
See 375
External callbacks from the Secret Fetcher
The secret fetcher daemon can now call an external executable after every time the secrets file is updated. This can be used to transform the secrets JSON into a format needed by non-baseplate services like nginx etc. and even do things like reload those services after changes.
[See the documentation for more information](https://github.com/reddit/baseplate.py/blob/1ca8488bcd42c8786e6a3db35b2a99517fd07a99/baseplate/sidecars/secrets_fetcher.py#L57-L60)
See 380
Changes
* The authentication token from edge context now has extra fields for `loid`, `loid_created_ms`, and `scopes`. (See 371)
* Simplify passing `app_config` to the `Baseplate` object and its calls. (See 375)
* The `active_requests` metric now tracks requests rather than connections. Previously, it counted all open connections to the service which would include any idle ones. The original metric is still available as `open_connections`. (See 376)
* `baseplate-tshell` has been renamed to `baseplate-shell` and can be used for all types of services, including Pyramid. (See 369)
* Performance improvements when validating invalid message signatures. (152bb8384).
* The `max_concurrency` setting on Thrift and WSGI servers is now deprecated. [See here for more information](https://github.com/reddit/baseplate.py-upgrader/wiki/v1.2#max_concurrency-is-deprecated). (`max_concurrency` is not deprecated for queue consumers) (See 382)
Bug Fixes
* Fix imports in generated thrift remote when `setup.py build` is run multiple times. (See 373)
* Fix an infinite loop when setting up Sentry's Raven client in a subdirectory via relative paths. (See 374)
Upgrading
No code or configuration changes are strictly required to upgrade, but there are some things to pay attention to.
Concurrency and timeouts
Without any other code changes, two things will happen:
* All requests will get a 10 second default timeout.
* You'll get a deprecation warning about the `max_concurrency` setting in your server config.
You can configure stricter timeouts to improve your service's resiliency, see [the timeout documentation for more information](https://baseplate.readthedocs.io/en/v1.2.0/api/baseplate/observers/timeout.html).
Once you've deployed, you can remove the `max_concurrency` setting to get rid of its sharp edges. (Don't do it until the code's fully out as it's required by Baseplate.py 1.1 and below).
Optional application startup change
An unrelated optional change you can make reduces some boilerplate during application startup and might make future framework-level settings more automatic:
diff
--- a/my_service/__init__.py
+++ b/my_service/__init__.py
-107,9 +107,9 class Handler:
def make_processor(app_config: config.RawConfig) -> TProcessor: pragma: nocover
cfg = config.parse_config(app_config, {"activity": {"window": config.Timespan}})
- baseplate = Baseplate()
- baseplate.configure_observers(app_config)
- baseplate.configure_context(app_config, {"redis": RedisClient(timeout=0.1)})
+ baseplate = Baseplate(app_config)
+ baseplate.configure_observers()
+ baseplate.configure_context({"redis": RedisClient(timeout=0.1)})