Adding timer variables in Mule flows to check for performance bottlenecks.
<set-variable value="#[%dw 2.0 import currentMilliseconds from dw::util::Timer --- currentMilliseconds()]"
variableName="http_before" doc:name="http_before" mimeType="application/java"/>
Logging via json-logger custom keys.
Note:
- dont forget to
default 0
if there is chance of timer variables not getting set in the flow due to choice blocks. - wrap each
var.xyz default 0
expression with brackets so that the subtraction expression evaluates correctly.
<json-logger:logger doc:name="Log End" doc:id="59b7a68f-77b6-4aa4-8a44-4496712eaa96"
config-ref="JSON_Logger_Config" tracePoint="END" logCategory="#[vars.logCategory]"
customKeys="#[{ http_time: (vars.http_after default 0) - (vars.http_before default 0), dwl_resp_mapper_time: (vars.dwl_resp_after default 0) - (vars.dwl_resp_before default 0) }]" />