Implements a request filter that automatically collects performance notifications
during a request and adds them to the Server-Timing
heading in the response, this enables the web development tools to show server timing information to
better analyze the timing of a request/response cycle.
Add a WAPerformanceTimingFilter
to your request handler as follows:
myApp := (WADispatcher default handlerAt: 'myApp')
addFilter: WAPerformanceTimingFilter new
Then in your code you signal performance notifications as follows:
(WAPerformanceTiming name: 'callback' description: 'Callback procesing' duration: 80 milliseconds) signal
You can also do:
WAPerformanceTiming measure: 'metricName' during: aBlock
Metacello new
baseline: 'SeasidePerformanceTiming';
repository: 'github://eMaringolo/seaside-server-timing/src';
onConflictUseLoaded; "Just in case you have an older version of Seaside Installed"
load.
Seaside's WAHeaderFields
object corectly supports adding multiple values for the same header name via aWAHeaderFields at: key add: value
or via aWAResponse headerAt: key append: value
.
But the ZnZincServerAdaptor>>responseFrom: aRequestContext
iteration over such headers only adds the last one. For this reason the filter manually updates the header value each time, breaking somehow the the encapsulation of WAHeaderFields
. Once this is solved at the ZnZincServerAdaptor
side, this behavior should be removed from the WAPerformanceTimingFilter
.
Each timing notification gets immediately added to the request header, so there is no "counter" functionality of each indicator. It is, if you signal a WAPerformanceTiming
with the same name twice, this will be added twice as well to the headers. So it doesn't work as a performance counter of any sort.