Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
Last active October 27, 2025 05:17
Show Gist options
  • Select an option

  • Save aimtiaz11/0a2fd447b745900310bd9be42517e89f to your computer and use it in GitHub Desktop.

Select an option

Save aimtiaz11/0a2fd447b745900310bd9be42517e89f to your computer and use it in GitHub Desktop.
Adding Timer Variables in Mule Flows

Adding Timer Variables in Mule Flows

Adding timer variables in Mule flows to check for performance bottlenecks.

Setting Timer Variable set-variable

<set-variable value="#[%dw 2.0 import currentMilliseconds from dw::util::Timer --- currentMilliseconds()]" 
              variableName="http_before" doc:name="http_before" mimeType="application/java"/>

Sample Logging via json-logger

Logging via json-logger custom keys.

Note:

  1. dont forget to default 0 if there is chance of timer variables not getting set in the flow due to choice blocks.
  2. wrap each var.xyz default 0 expression with brackets so that the subtraction expression evaluates correctly.
  3. Always add at the last json-logger of the flow so the metrics are visible in one place.
<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) }]" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment