ctx.run() closures at the endpoint, service, or handler level. They are useful for integrating observability libraries, adding custom logging, or implementing other cross-cutting concerns.
How hooks work
A hook is aHooksProvider function that receives the invocation request context and returns interceptors:
HooksProvider receives a context with ctx.request, which includes:
ctx.request.target— the invocation target (e.g.MyService/myHandler)ctx.request.id— the invocation ID
The
handler interceptor fires on every attempt. The run interceptor only fires when a ctx.run() closure executes. If the result is already in the journal (replay), the closure and its interceptor are skipped.