Skip to content

Commit c4c9027

Browse files
committed
HPCC-35868 Ensure graphs have an end time for metrics
Mark on failure, fake one for running Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
1 parent ebda4c0 commit c4c9027

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

esp/src/src/Timings.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,19 @@ export class WUTimelineNoFetch extends WUTimelinePatched {
8383
scope.__hpcc_id = scope.name;
8484
}
8585
return scope.id &&
86-
scope.WhenStarted && (scope.WhenFinished || scope.TimeElapsed) &&
86+
scope.WhenStarted &&
8787
scope.type !== "activity";
8888
}).map((scope: IScope) => {
8989
let whenFinished = scope.WhenFinished;
9090
if (!whenFinished) {
91-
const d = new Date(scope.WhenStarted);
92-
d.setMilliseconds(d.getMilliseconds() + scope.TimeElapsed * 1000);
93-
whenFinished = d.toISOString();
91+
if (scope.TimeElapsed) {
92+
const d = new Date(scope.WhenStarted);
93+
d.setMilliseconds(d.getMilliseconds() + scope.TimeElapsed * 1000);
94+
whenFinished = d.toISOString();
95+
} else {
96+
// Graph still running — use current time as a placeholder end
97+
whenFinished = new Date().toISOString();
98+
}
9499
}
95100
return [
96101
scope.id,

thorlcr/master/thgraphmanager.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,20 @@ bool CJobManager::executeGraph(IConstWorkUnit &workunit, const char *graphName,
11711171
{
11721172
exception.setown(ThorWrapException(e, "CJobManager::executeGraph"));
11731173
e->Release();
1174+
try
1175+
{
1176+
Owned<IWorkUnit> wu = &workunit.lock();
1177+
unsigned __int64 graphTimeNs = cycle_to_nanosec(get_cycles_now()-startCycles);
1178+
StringBuffer graphTimeStr;
1179+
formatGraphTimerLabel(graphTimeStr, graphName);
1180+
updateWorkunitStat(wu, SSTgraph, graphName, StTimeElapsed, graphTimeStr, graphTimeNs, wfid);
1181+
addTimeStamp(wu, SSTgraph, graphName, StWhenFinished, wfid);
1182+
}
1183+
catch (IException *e2)
1184+
{
1185+
EXCLOG(e2, "Failed to record graph end time");
1186+
e2->Release();
1187+
}
11741188
}
11751189
job->endJob();
11761190
removeJob(*job);

0 commit comments

Comments
 (0)