Skip to content

Commit 02e726f

Browse files
Joe Creankkanthet
authored andcommitted
#1845 add flow name to the error record written to the jobs db, creat… (#1870)
* #1845 add flow name to the error record written to the jobs db, create a getter for this data * #1845 fix typed assignment
1 parent 6efe743 commit 02e726f

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/run-flow-context.sjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ function getFlow() {
109109
return getGlobalContext().flow;
110110
}
111111

112+
function getFlowName() {
113+
return getFlow().name;
114+
}
115+
112116
function getFlowType() {
113117
return getGlobalContext()['flow-type'];
114118
}
@@ -170,6 +174,7 @@ module.exports = {
170174
withOptions: withOptions,
171175
withTrace: withTrace,
172176
getFlow: getFlow,
177+
getFlowName: getFlowName,
173178
getFlowType: getFlowType,
174179
getModuleUri: getModuleUri,
175180
getCodeFormat: getCodeFormat,

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/run-flow-context.xqy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ declare function rfc:get-flow() as element(hub:flow)
121121
map:get($context, "flow")
122122
};
123123

124+
declare function rfc:get-flow-name() as xs:string
125+
{
126+
let $flow as element(hub:flow) := rfc:get-flow()
127+
return $flow/hub:name
128+
};
129+
124130
declare function rfc:get-flow-type() as xs:string
125131
{
126132
map:get($context, "flow-type")

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/trace-lib.sjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function writeErrorTrace(itemContext) {
196196
traceId: currentTrace.traceId,
197197
created: currentTrace.created,
198198
identifier: rfc.getId(itemContext),
199+
flowName: rfc.getFlowName(),
199200
flowType: rfc.getFlowType(),
200201
hasError: false,
201202
steps: []
@@ -231,6 +232,9 @@ function writeErrorTrace(itemContext) {
231232
nb.startElement("identifier");
232233
nb.addText(rfc.getId(itemContext).toString());
233234
nb.endElement();
235+
nb.startElement("flowName");
236+
nb.addText(rfc.getFlowName().toString());
237+
nb.endElement();
234238
nb.startElement("flowType");
235239
nb.addText(rfc.getFlowType().toString());
236240
nb.endElement();

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/trace-lib.xqy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ declare %private function trace:write-error-trace(
240240
map:entry("traceId", map:get($current-trace, "traceId")),
241241
map:entry("created", map:get($current-trace, "created")),
242242
map:entry("identifier", rfc:get-id($item-context)),
243+
map:entry("flowName", rfc:get-flow-name() ),
243244
map:entry("flowType", rfc:get-flow-type()),
244245
map:entry("hasError", trace:has-errors()),
245246
let $steps := json:array()
@@ -260,6 +261,7 @@ declare %private function trace:write-error-trace(
260261
element traceId { map:get($current-trace, "traceId") },
261262
element created { map:get($current-trace, "created") },
262263
element identifier { rfc:get-id($item-context) },
264+
element flowName { rfc:get-flow-name() },
263265
element flowType { rfc:get-flow-type() },
264266
element hasError { trace:has-errors() },
265267
element steps {

0 commit comments

Comments
 (0)