Runtime Interceptors
Sparta uses runtime interceptors to hook into
the event handling workflow. Interceptors provide an opportunity to handle concerns (logging, metrics, etc) independent
of core event handling workflow.
%%{init: {'themeVariables': { 'fontFamily': 'Inconsolata, Avenir, Helvetica, sans-serif', 'primaryColor': '#ff0000'}}}%%
graph TD
classDef stdOp fill:#FFF,stroke:#A00,stroke-width:2px;
classDef userHook fill:#aaa,stroke:#A00,stroke-width:2px;
execute[Execute]
class execute stdOp;
lookup[Lookup Function]
class lookup stdOp;
call[Call Function]
class call stdOp;
interceptorBegin[Interceptor Begin]
class interceptorBegin userHook;
populateLogger[Logger into context]
class populateLogger stdOp;
interceptorBeforeSetup[Interceptor BeforeSetup]
class interceptorBeforeSetup userHook;
interceptorAfterSetup[Interceptor AfterSetup]
class interceptorAfterSetup userHook;
populateContext[Populate context]
class populateContext stdOp;
unmarshalArgs[Introspect Arguments]
class unmarshalArgs stdOp;
interceptorBeforeDispatch[Interceptor BeforeDispatch]
class interceptorBeforeDispatch userHook;
callFunction[Call Function]
class callFunction stdOp;
interceptorAfterDispatch[Interceptor AfterDispatch]
class interceptorAfterDispatch userHook;
extractReturn[Extract Function Return]
class extractReturn stdOp;
interceptorComplete[Interceptor Complete]
class interceptorComplete userHook;
done[Done]
class done stdOp;
execute-->lookup
lookup-->call
call-->interceptorBegin
interceptorBegin-->populateLogger
populateLogger-->interceptorBeforeSetup
interceptorBeforeSetup-->populateContext
populateContext-->interceptorAfterSetup
interceptorAfterSetup-->unmarshalArgs
unmarshalArgs-->interceptorBeforeDispatch
interceptorBeforeDispatch-->callFunction
callFunction-->interceptorAfterDispatch
interceptorAfterDispatch-->extractReturn
extractReturn-->interceptorComplete
interceptorComplete-->done
This diagram is rendered with Mermaid. Please open an issue if it doesn't render properly.
Available Interceptors
-
XRayInterceptor
Interceptors that ensure observatility information is sent to X-Ray
TODO: Document the XRayInterceptor
🎉 Sparta v1.7.0: The Time Machine Edition 🕰 🎉 For those times when you wish you could go back in time and enable debug logging for a single request.https://t.co/BP60qQpKva#serverless #go
— Matt Weagle (@mweagle) November 12, 2018 Sparta v1.7.0 adds `Interceptors`: user defined hooks called during the lambda event handling flow to support cross-cutting concerns.