Skip to content

Commit

Permalink
traceevent.core: fix timestamp in raw
Browse files Browse the repository at this point in the history
No longer show raw value * 1000

[fixed] raw timestamp display in events table for trace events

Change-Id: I0b7d88120c1e29883251d04b842b0f542dd08cf4
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/169694
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
  • Loading branch information
MatthewKhouzam committed Sep 23, 2020
1 parent 0ae50c8 commit ab4887a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -330,7 +330,7 @@ public void testEmptyEvent() throws TmfTraceException {
assertEquals("event1", eventField.getField("name").getValue());
assertEquals("12", eventField.getField("pid").getValue());
assertEquals(12, eventField.getField("tid").getValue());
assertEquals(456123453000L, eventField.getField("ts").getValue());
assertEquals("456123453", eventField.getField("ts").getValue()); // it's in microseconds
} finally {
trace.dispose();
}
Expand Down
Expand Up @@ -76,10 +76,11 @@ public class TraceEventField {
if (root.size() == 0) {
return null;
}
Double tso = optDouble(root, ITraceEventConstants.TIMESTAMP);
if (tso == Double.NaN) {
JsonElement timestamp = root.get(ITraceEventConstants.TIMESTAMP);
if (timestamp == null) {
return null;
}
Double tso = timestamp.getAsDouble();
if (Double.isFinite(tso)) {
ts = (long) (tso * MICRO_TO_NANO);
}
Expand Down Expand Up @@ -113,7 +114,7 @@ public class TraceEventField {
argsMap.put(ITraceEventConstants.ARGS + "/" + key, value); //$NON-NLS-1$
}
}
argsMap.put(ITraceEventConstants.TIMESTAMP, ts);
argsMap.put(ITraceEventConstants.TIMESTAMP, timestamp.getAsString());
argsMap.put(ITraceEventConstants.PHASE, phase);
argsMap.put(ITraceEventConstants.NAME, name);
if (tid != null) {
Expand Down Expand Up @@ -193,6 +194,7 @@ protected TraceEventField(String name, long ts, String phase, @Nullable Object p
.map(entry -> new TmfEventField(entry.getKey(), entry.getValue(), null))
.toArray(ITmfEventField[]::new);
fContent = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, fields, array);
fields.put(ITraceEventConstants.TIMESTAMP, ts / MICRO_TO_NANO);
fTs = ts;
fDuration = duration == null ? null : Double.isFinite(duration) ? duration.longValue() : null;
fPhase = phase.charAt(0);
Expand Down

0 comments on commit ab4887a

Please sign in to comment.