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.

graph TD classDef stdOp fill:#FFF,stroke:#A00,stroke-width:2px; classDef userHook fill:#B5B2A1,stroke:#A00,stroke-width:2px,stroke-dasharray: 5, 5; 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; populateContext[Populate context] class populateContext stdOp; interceptorAfterSetup[Interceptor AfterSetup] class interceptorAfterSetup userHook; 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
  • 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. #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. The first interceptor is an XRay annotation and metadata interceptor.