Skip to content

Commit 084b860

Browse files
committed
Throws error only after logging out metrics
1 parent 28b117c commit 084b860

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/core/src/mapping-kit/liquid-directive.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,25 @@ export function evaluateLiquid(liquidValue: any, event: any, statsContext?: Stat
7474
throw new Error('liquid template values are limited to 1000 characters')
7575
}
7676

77-
let status = 'success'
7877
let res
7978
const start = performance.now()
79+
let duration
8080
try {
8181
res = liquidEngine.parseAndRenderSync(liquidValue, event)
82-
} catch (_e) {
83-
status = 'fail'
82+
} catch (e) {
83+
duration = performance.now() - start
84+
85+
statsContext?.statsClient?.histogram('liquid.template.evaluation_ms', duration, [
86+
...statsContext.tags,
87+
`result:fail` // status = success/fail, not in the psudocode for simplicity
88+
])
89+
throw e
8490
}
85-
const duration = performance.now() - start
91+
duration = performance.now() - start
8692

8793
statsContext?.statsClient?.histogram('liquid.template.evaluation_ms', duration, [
8894
...statsContext.tags,
89-
`result:${status}` // status = success/fail, not in the psudocode for simplicity
95+
`result:success` // status = success/fail, not in the psudocode for simplicity
9096
])
9197

9298
if (typeof res !== 'string') {

0 commit comments

Comments
 (0)