private long elapsedMillis(final Task<?> task) { final ShallowTrace trace = task.getShallowTrace(); return (trace.getEndNanos() - trace.getStartNanos()) / 1000000; } }
private void recordCompletionTimes(final Histogram planHistogram, Histogram taskHistogram, Task<?> task) { ShallowTrace st = task.getShallowTrace(); planHistogram.recordValue(st.getEndNanos() - st.getStartNanos()); task.getTrace().getTraceMap().values().forEach(shallowTrace -> { taskHistogram.recordValue(shallowTrace.getPendingNanos() - shallowTrace.getStartNanos()); }); }
public ShallowTraceBuilder(final ShallowTrace shallowTrace) { this(shallowTrace.getId()); setResultType(shallowTrace.getResultType()); setName(shallowTrace.getName()); setValue(shallowTrace.getValue()); setStartNanos(shallowTrace.getStartNanos()); setPendingNanos(shallowTrace.getPendingNanos()); setEndNanos(shallowTrace.getEndNanos()); setHidden(shallowTrace.getHidden()); setSystemHidden(shallowTrace.getSystemHidden()); Map<String, String> attributes = shallowTrace.getAttributes(); if (!attributes.isEmpty()) { _attributes = new HashMap<String, String>(); _attributes.putAll(attributes); } setTaskType(shallowTrace.getTaskType()); }
if (trace.getEndNanos() != null) { generator.writeNumberField(JsonTraceCodec.TRACE_END_NANOS, trace.getEndNanos());
assertNull(trace.getEndNanos()); } else { assertTrue(trace.getEndNanos() <= System.nanoTime()); assertTrue(trace.getEndNanos() > trace.getStartNanos());
private void assertCancelled(final Task<?> task, Exception exception) { assertTrue(task.isDone()); assertTrue(task.isFailed()); assertTrue(Exceptions.isCancellation(task.getError())); assertEquals(exception, task.getError().getCause()); assertTrue(task.getShallowTrace().getStartNanos() > 0); assertTrue(task.getShallowTrace().getStartNanos() <= task.getShallowTrace().getEndNanos()); try { task.get(); fail("Should have thwon PromiseException"); } catch (PromiseException e) { assertEquals(exception, e.getCause().getCause()); } }
private <T> void assertDone(final Task<T> task, final T expectedValue) { assertTrue(task.isDone()); assertFalse(task.isFailed()); assertEquals(expectedValue, task.get()); assertNull(task.getError()); assertTrue(task.getShallowTrace().getStartNanos() > 0); assertTrue(task.getShallowTrace().getStartNanos() <= task.getShallowTrace().getEndNanos()); }
private void assertRunOrPending(final Task<?> task) { assertFalse(task.isDone()); assertFalse(task.isFailed()); assertTrue(task.getShallowTrace().getStartNanos() > 0); assertNotNull(task.getShallowTrace().getEndNanos()); try { task.get(); fail("Should have thrown PromiseUnresolvedException"); } catch (PromiseUnresolvedException e) { // Expected case } try { task.getError(); fail("Should have thrown PromiseUnresolvedException"); } catch (PromiseUnresolvedException e) { // Expected case } }
private void assertInitOrScheduled(final Task<?> task) { assertFalse(task.isDone()); assertFalse(task.isFailed()); assertNull(task.getShallowTrace().getStartNanos()); assertNull(task.getShallowTrace().getEndNanos()); try { task.get(); fail("Should have thrown PromiseUnresolvedException"); } catch (PromiseUnresolvedException e) { // Expected case } try { task.getError(); fail("Should have thrown PromiseUnresolvedException"); } catch (PromiseUnresolvedException e) { // Expected case } }
private void assertFailed(final Task<?> task, Exception exception) { assertTrue(task.isDone()); assertTrue(task.isFailed()); assertEquals(exception, task.getError()); assertTrue(task.getShallowTrace().getStartNanos() > 0); assertTrue(task.getShallowTrace().getStartNanos() <= task.getShallowTrace().getEndNanos()); try { task.get(); fail("Should have thwon PromiseException"); } catch (PromiseException e) { assertEquals(exception, e.getCause()); } }
private long elapsedMillis(final Task<?> task) { final ShallowTrace trace = task.getShallowTrace(); return (trace.getEndNanos() - trace.getStartNanos()) / 1000000; } }
public ShallowTraceBuilder(final ShallowTrace shallowTrace) { this(shallowTrace.getId()); setResultType(shallowTrace.getResultType()); setName(shallowTrace.getName()); setValue(shallowTrace.getValue()); setStartNanos(shallowTrace.getStartNanos()); setPendingNanos(shallowTrace.getPendingNanos()); setEndNanos(shallowTrace.getEndNanos()); setHidden(shallowTrace.getHidden()); setSystemHidden(shallowTrace.getSystemHidden()); Map<String, String> attributes = shallowTrace.getAttributes(); if (!attributes.isEmpty()) { _attributes = new HashMap<String, String>(); _attributes.putAll(attributes); } setTaskType(shallowTrace.getTaskType()); }
if (trace.getEndNanos() != null) { generator.writeNumberField(JsonTraceCodec.TRACE_END_NANOS, trace.getEndNanos());