Skip to content

Commit

Permalink
FIXUP: node start and end times are relative
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenny Burdette committed Sep 6, 2019
1 parent 5d17cc2 commit d7109aa
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters;
import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters;
import graphql.schema.DataFetchingEnvironment;
import mdg.engine.proto.Reports;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -76,7 +75,14 @@ public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchP
long endNanos = System.nanoTime();

ExecutionStepInfo executionStepInfo = parameters.getEnvironment().getExecutionStepInfo();
state.addNode(executionStepInfo, startNanos, endNanos, convertErrors(throwable, result));
state.addNode(
executionStepInfo,
// relative to the trace's start_time, in ns
startNanos - state.getStartRequestNanos(),
// relative to the trace's start_time, in ns
endNanos - state.getStartRequestNanos(),
convertErrors(throwable, result)
);
});
}

Expand Down Expand Up @@ -181,6 +187,10 @@ Reports.Trace.Node.Builder getParent(ExecutionPath path) {
return nodesByPath.get(parentPath);
}

public long getStartRequestNanos() {
return startRequestNanos;
}

private Timestamp getStartTimestamp() {
return Timestamp.newBuilder()
.setSeconds(startRequestTime.getEpochSecond())
Expand All @@ -195,7 +205,7 @@ private Timestamp getNowTimestamp() {
.build();
}

public long getDuration() {
private long getDuration() {
return System.nanoTime() - startRequestNanos;
}
}
Expand Down

0 comments on commit d7109aa

Please sign in to comment.