Add WSGI middleware to the pipeline¶
This guide shows you how to inject WSGI/PasteDeploy filters into the generated
zope.ini pipeline – for example the request-metrics and OpenTelemetry
middleware from plone.observability.
Prerequisites¶
New to this template? Start with Your first Zope instance.
The middleware package must be installed and expose a
paste.filter_app_factoryentry point.
Step 1: define the filters¶
Set wsgi_filters in your instance.yaml to a dictionary. Each key is the
filter name; its value configures that filter:
default_context:
wsgi_filters:
observability:
use: "egg:plone.observability#observability"
opentelemetry:
use: "egg:plone.observability#opentelemetry"
Each entry’s value supports these fields:
use(required) – the PasteDeploy entry point of the filter.options(optional) – a mapping of additionalkey: valuelines rendered verbatim into the[filter:<name>]section.position(optional) –outer(the default) places the filter ahead of the built-inprofile/transloggerfilters, so it wraps the whole request;innerplaces it closest to the application, just beforeegg:Zope#httpexceptions.
Reserved names that cannot be used: zope, profile, translogger,
httpexceptions, main.
Step 2: check the generated output¶
This renders one [filter:<name>] section per entry, wired into
[pipeline:main]:
[pipeline:main]
pipeline =
observability
opentelemetry
egg:Zope#httpexceptions
zope
[filter:observability]
use = egg:plone.observability#observability
[filter:opentelemetry]
use = egg:plone.observability#opentelemetry
Next steps¶
Basic configuration – Reference for
wsgi_filtersand the other core settings.