Skip to content

Commit b81f844

Browse files
committed
fixing traces inside of trace appserver
1 parent 47ee05c commit b81f844

File tree

16 files changed

+712
-152
lines changed

16 files changed

+712
-152
lines changed

marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public List<String> updateLegacyFlows(String fromVersion, String entityName) thr
144144
Path harmonizeDir = entityDir.resolve("harmonize");
145145

146146

147+
updateLegacyEntity(entityName);
148+
147149
List<String> updatedFlows = new ArrayList<>();
148150
File[] inputFlows = inputDir.toFile().listFiles((pathname) -> pathname.isDirectory() && !pathname.getName().equals("REST"));
149151
if (inputFlows != null) {
@@ -166,6 +168,20 @@ public List<String> updateLegacyFlows(String fromVersion, String entityName) thr
166168
return updatedFlows;
167169
}
168170

171+
public void updateLegacyEntity(String entityName) {
172+
Path entityDir = entitiesDir.resolve(entityName);
173+
174+
File[] entityFiles = entityDir.toFile().listFiles((dir, name) -> name.matches("[^.]+\\.entity\\.json"));
175+
if (entityFiles.length == 0) {
176+
try {
177+
String fileContents = getFileContent("scaffolding/Entity.json", entityName);
178+
writeToFile(fileContents, entityDir.resolve(entityName + ".entity.json").toFile());
179+
} catch (IOException e) {
180+
e.printStackTrace();
181+
}
182+
}
183+
}
184+
169185
public boolean updateLegacyFlow(String fromVersion, String entityName, String flowName, FlowType flowType) throws IOException {
170186
boolean updated = false;
171187

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

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ declare function trace:_walk_json($nodes as node()* ,$o)
396396
map:put($o, $name, $unquoted)
397397
else if ($name = "error") then
398398
map:put($o, $name, $n)
399+
else if ($name = ("collectorPlugin", "contentPlugin", "headersPlugin", "triplesPlugin", "writerPlugin")) then
400+
()
399401
else
400402
let $_ := trace:_walk_json($n/node(), $oo)
401403
return
@@ -452,19 +454,48 @@ declare function trace:_walk_json($nodes as node()* ,$o)
452454
$n
453455
};
454456

455-
declare function trace:trace-to-json($trace)
457+
declare function trace:trace-to-json-legacy($trace)
456458
{
457459
let $o := json:object()
458-
let $walk-me :=
459-
let $n := $trace/node()
460+
let $_ :=
461+
for $n in $trace/node()
462+
let $name := fn:string(fn:node-name($n))
463+
where fn:not($name = ("collectorPlugin", "contentPlugin", "headersPlugin", "triplesPlugin", "writerPlugin"))
460464
return
461-
if ($n instance of object-node()) then
462-
$n/node()
463-
else
464-
$n
465-
let $_ := trace:_walk_json($walk-me, $o)
466-
return
467-
$o
465+
map:put($o, $name, $n/data())
466+
let $steps := json:array()
467+
let $_build_steps :=
468+
for $n in $trace/node()
469+
let $name := fn:string(fn:node-name($n))
470+
where $name = ("collectorPlugin", "contentPlugin", "headersPlugin", "triplesPlugin", "writerPlugin")
471+
return
472+
let $step := json:object()
473+
let $_ := map:put($step, "label", fn:replace($name, "Plugin", ""))
474+
let $_ :=
475+
trace:_walk_json($n/node(), $step)
476+
return
477+
json:array-push($steps, $step)
478+
let $_ := map:put($o, "steps", $steps)
479+
return $o
480+
};
481+
482+
483+
declare function trace:trace-to-json($trace)
484+
{
485+
if (fn:exists($trace/steps)) then
486+
let $o := json:object()
487+
let $walk-me :=
488+
let $n := $trace/node()
489+
return
490+
if ($n instance of object-node()) then
491+
$n/node()
492+
else
493+
$n
494+
let $_ := trace:_walk_json($walk-me, $o)
495+
return
496+
$o
497+
else
498+
trace:trace-to-json-legacy($trace)
468499
};
469500

470501
declare function trace:trace-to-json-slim($trace)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"info" : {
3+
"title" : "placeholder",
4+
"version" : "0.0.1"
5+
},
6+
"definitions" : {
7+
"placeholder" : {
8+
"required" : [ ],
9+
"rangeIndex" : [ ],
10+
"wordLexicon" : [ ],
11+
"properties" : { }
12+
}
13+
}
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"trace":{"format":"xml", "identifier":"/34324.json", "flowType":"input", "contentPlugin":{"duration":"PT0.021033S", "pluginModuleUri":"/entities/Employee/input/load-acme-tech/content/content.sjs", "input":{"rawContent":{"id":"34324", "firstName":"Robert", "lastName":"Smith", "dateOfBirth":"01/01/1981", "hireDate":"12/19/2005", "salaryHistory":[{"effectiveDate":"12/21/2005", "salary":59832}, {"effectiveDate":"05/14/2009", "salary":60832}]}}, "error":{"code":"error", "name":"boom", "xqueryVersion":"javascript", "message":"error", "formatString":"error (boom): fn.error(xs.QName('boom')); -- ", "retryable":"false", "expr":"fn.error(xs.QName('boom'));", "data":[], "stacks":[{"uri":"/entities/Employee/input/load-acme-tech/content/content.sjs", "line":"11", "column":"5", "operation":"createContent()", "xqueryVersion":"javascript", "variables":{}}, {"uri":"/entities/Employee/input/load-acme-tech/content/content.sjs", "line":"698", "column":"6", "operation":"flow:call-plugin-function(<plugin dest=\"content\" type=\"javascript\" module=\"/entities/Employee...\" .../>, \"/34324.json\", document{object-node{\"id\":text{\"34324\"}, \"firstName\":text{\"Robert\"}, \"lastName\":text{\"Smith\"}, ...}}, (), (), \"input\", fn:true(), map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>))", "xqueryVersion":"javascript", "variables":{}}, {"uri":"/com.marklogic.hub/lib/flow-lib.xqy", "line":"698", "column":"6", "operation":"flow:run-plugin(<plugin dest=\"content\" type=\"javascript\" module=\"/entities/Employee...\" .../>, <data-format xmlns=\"http://marklogic.com/data-hub\">application/json</data-format>, \"/34324.json\", document{object-node{\"id\":text{\"34324\"}, \"firstName\":text{\"Robert\"}, \"lastName\":text{\"Smith\"}, ...}}, (), (), <type xmlns=\"http://marklogic.com/data-hub\">input</type>, fn:true(), map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>))", "xqueryVersion":"1.0-ml", "variables":{"plugin":"<plugin dest=\"content\" type=\"javascript\" module=\"/entities/Employee...\" .../>", "data-format":"\"application/json\"", "identifier":"\"/34324.json\"", "content":"document{object-node{\"id\":text{\"34324\"}, \"firstName\":text{\"Robert\"}, \"lastName\":text{\"Smith\"}, ...}}", "headers":"()", "triples":"()", "flow-type":"\"input\"", "simple":"fn:true()", "options":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "module-uri":"\"/entities/Employee/input/load-acme-tech/content/content.sjs\"", "destination":"\"content\"", "trace-input":"json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "before":"xs:dayTimeDuration(\"PT0.215026S\")"}}, {"uri":"/com.marklogic.hub/lib/flow-lib.xqy", "line":"513", "column":"6", "operation":"flow:run-plugins(<flow xmlns=\"http://marklogic.com/data-hub\"><name>load-acme-tech</name>...</flow>, \"/34324.json\", document{object-node{\"id\":text{\"34324\"}, \"firstName\":text{\"Robert\"}, \"lastName\":text{\"Smith\"}, ...}}, map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>))", "xqueryVersion":"1.0-ml", "variables":{"flow":"<flow xmlns=\"http://marklogic.com/data-hub\"><name>load-acme-tech</name>...</flow>", "identifier":"\"/34324.json\"", "content":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "options":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "data-format":"<data-format xmlns=\"http://marklogic.com/data-hub\">application/json</data-format>", "flow-type":"<type xmlns=\"http://marklogic.com/data-hub\">input</type>", "flow-complexity":"<complexity xmlns=\"http://marklogic.com/data-hub\">simple</complexity>", "_":"()", "plugin":"<plugin dest=\"content\" type=\"javascript\" module=\"/entities/Employee...\" .../>", "destination":"attribute{fn:QName(\"\",\"dest\")}{\"content\"}"}}, {"uri":"/com.marklogic.hub/mlcp-flow-transform.xqy", "line":"44", "column":"23", "operation":"function() as item()*()", "xqueryVersion":"1.0-ml", "variables":{"context":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "params":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "flow":"<flow xmlns=\"http://marklogic.com/data-hub\"><name>load-acme-tech</name>...</flow>", "_":"()"}}, {"uri":"/com.marklogic.hub/lib/perflog-lib.xqy", "line":"33", "column":"9", "operation":"perf:log(\"mlcp-flow-transform(/34324.json)\", function() as item()*)", "xqueryVersion":"1.0-ml", "variables":{"what":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "func":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)"}}, {"uri":"/com.marklogic.hub/mlcp-flow-transform.xqy", "line":"25", "column":"4", "operation":"xdmp:function(fn:QName(\"http://marklogic.com/data-hub/mlcp-flow-transform\",\"transform\"), \"/com.marklogic.hub/mlcp-flow-transform.xqy\")(map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>), map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>))", "xqueryVersion":"1.0-ml", "variables":{"content":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "context":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "uri":"\"/34324.json\""}}, {"uri":"/MarkLogic/hadoop.xqy", "line":"374", "column":"5", "operation":"transform-insert-item(\"/com.marklogic.hub/mlcp-flow-transform.xqy\", xs:untypedAtomic(\"http://marklogic.com/data-hub/mlcp-flow-transform\"), \"transform\", xs:untypedAtomic(\"entity=Employee,flow=load-acme-tech,flowType=input,jobId=3c490f6...\"), \"/34324.json\", \"{&#10; &quot;id&quot;: &quot;34324&quot;,&#10; &quot;firstName...\", json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>), (), ())", "xqueryVersion":"1.0-ml", "variables":{"transform-module":"\"/com.marklogic.hub/mlcp-flow-transform.xqy\"", "transform-namespace":"\"http://marklogic.com/data-hub/mlcp-flow-transform\"", "transform-function":"\"transform\"", "transform-param":"\"entity=Employee,flow=load-acme-tech,flowType=input,jobId=3c490f6...\"", "uri":"\"/34324.json\"", "value":"\"{&#10; &quot;id&quot;: &quot;34324&quot;,&#10; &quot;firstName...\"", "options-map":"json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "modules":"()", "modules-root":"()", "value-type":"xs:untypedAtomic(\"xs:string\")", "namespace":"()", "language":"()", "roles-execute":"xs:untypedAtomic(\"\")", "roles-insert":"xs:untypedAtomic(\"\")", "roles-read":"xs:untypedAtomic(\"rest-reader\")", "roles-update":"xs:untypedAtomic(\"rest-writer\")", "roles-node-update":"xs:untypedAtomic(\"\")", "collections":"xs:untypedAtomic(\"Employee,load-acme-tech,input\")", "temporal-collection":"()", "quality":"xs:int(\"0\")", "xml-repair-level":"()", "permissions":"(<sec:permission xmlns:sec=\"http://marklogic.com/xdmp/security\"><sec:capability>...</sec:capability>...</sec:permission>, <sec:permission xmlns:sec=\"http://marklogic.com/xdmp/security\"><sec:capability>...</sec:capability>...</sec:permission>)", "context":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "dummy":"()", "newVal":"document{object-node{\"id\":text{\"34324\"}, \"firstName\":text{\"Robert\"}, \"lastName\":text{\"Smith\"}, ...}}", "content":"map:map(<map:map xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)"}}, {"uri":"/MarkLogic/hadoop.xqy", "line":"256", "column":"8", "operation":"hadoop:transform-insert-batch(\"/com.marklogic.hub/mlcp-flow-transform.xqy\", \"transform\", json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>), \"/34324.json\", \"{&#10; &quot;id&quot;: &quot;34324&quot;,&#10; &quot;firstName...\", json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>))", "xqueryVersion":"1.0-ml", "variables":{"transform-module":"\"/com.marklogic.hub/mlcp-flow-transform.xqy\"", "transform-function":"\"transform\"", "transform-option":"json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "uris":"\"/34324.json\"", "values":"\"{&#10; &quot;id&quot;: &quot;34324&quot;,&#10; &quot;firstName...\"", "insert-options":"json:object(<json:object xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" .../>)", "modules-name":"()", "modules":"()", "modules-root":"()", "transform-namespace":"xs:untypedAtomic(\"http://marklogic.com/data-hub/mlcp-flow-transform\")", "transform-param":"xs:untypedAtomic(\"entity=Employee,flow=load-acme-tech,flowType=input,jobId=3c490f6...\")", "uri":"\"/34324.json\"", "i":"1"}}, {"uri":"/eval", "line":"7", "column":"0", "xqueryVersion":"1.0-ml", "variables":{}}]}}, "hasError":true, "created":"2017-09-12T09:15:01.928285-07:00", "jobId":"3c490f69-288c-41fd-bc95-dec01437ab1a", "traceId":"9091223776754160124"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"trace":{"headersPlugin":{"duration":"PT0.001007S", "output":{}, "pluginModuleUri":"/entities/Employee/input/load-acme-tech/headers/headers.sjs", "input":{"content":{"id":"32920", "firstName":"Rosanne", "lastName":"Henckle", "dateOfBirth":"05/19/1979", "hireDate":"12/19/2005", "salaryHistory":[{"effectiveDate":"12/23/2005", "salary":63439}, {"effectiveDate":"01/14/2010", "salary":66300}]}}}, "format":"json", "identifier":"/32920.json", "flowType":"input", "contentPlugin":{"duration":"PT0.000632S", "output":{"id":"32920", "firstName":"Rosanne", "lastName":"Henckle", "dateOfBirth":"05/19/1979", "hireDate":"12/19/2005", "salaryHistory":[{"effectiveDate":"12/23/2005", "salary":63439}, {"effectiveDate":"01/14/2010", "salary":66300}]}, "pluginModuleUri":"/entities/Employee/input/load-acme-tech/content/content.sjs", "input":{"rawContent":{"id":"32920", "firstName":"Rosanne", "lastName":"Henckle", "dateOfBirth":"05/19/1979", "hireDate":"12/19/2005", "salaryHistory":[{"effectiveDate":"12/23/2005", "salary":63439}, {"effectiveDate":"01/14/2010", "salary":66300}]}}}, "writerPlugin":{"duration":"PT0S", "output":null, "pluginModuleUri":null, "input":{"triples":[], "headers":{}, "content":{"id":"32920", "firstName":"Rosanne", "lastName":"Henckle", "dateOfBirth":"05/19/1979", "hireDate":"12/19/2005", "salaryHistory":[{"effectiveDate":"12/23/2005", "salary":63439}, {"effectiveDate":"01/14/2010", "salary":66300}]}}}, "hasError":false, "created":"2017-09-12T08:27:01.343158-07:00", "triplesPlugin":{"duration":"PT0.000851S", "output":[], "pluginModuleUri":"/entities/Employee/input/load-acme-tech/triples/triples.sjs", "input":{"content":{"id":"32920", "firstName":"Rosanne", "lastName":"Henckle", "dateOfBirth":"05/19/1979", "hireDate":"12/19/2005", "salaryHistory":[{"effectiveDate":"12/23/2005", "salary":63439}, {"effectiveDate":"01/14/2010", "salary":66300}]}, "headers":{}}}, "jobId":"da0c156f-e3c0-4e3d-80fb-004f61b9365a", "traceId":"9054050403310939961"}}

0 commit comments

Comments
 (0)