Repository navigation
added missing call to onDispatched for instrumentation context of beginExecution - resolves #1620 - #2722
added missing call to onDispatched for instrumentation context of beginExecution - resolves #1620#2722bsara wants to merge 1 commit into
Conversation
c24a1a1 to
c9cc5ab
Compare
There was a problem hiding this comment.
Thanks for this fix - it is indeed missing. But its slightly wrong in this fix
Tthis should be before the method parseValidateAndExecute
The idea of onDispacthed is indicate that an instrumented stage is now really underway with a CF promise to it being completed.
With a sync process like this it should be immediately after its called. That is its dispatched immediately. Near zero nanos later.
It should be this
public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput executionInput) {
try {
if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Executing request. operation name: '{}'. query: '{}'. variables '{}'", executionInput.getOperationName(), executionInput.getQuery(), executionInput.getVariables());
}
executionInput = ensureInputHasId(executionInput);
InstrumentationState instrumentationState = instrumentation.createState(new InstrumentationCreateStateParameters(this.graphQLSchema, executionInput));
InstrumentationExecutionParameters inputInstrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema, instrumentationState);
executionInput = instrumentation.instrumentExecutionInput(executionInput, inputInstrumentationParameters);
CompletableFuture<ExecutionResult> beginExecutionCF = new CompletableFuture<>();
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema, instrumentationState);
InstrumentationContext<ExecutionResult> executionInstrumentation = instrumentation.beginExecution(instrumentationParameters);
executionInstrumentation.onDispatched(beginExecutionCF);
GraphQLSchema graphQLSchema = instrumentation.instrumentSchema(this.graphQLSchema, instrumentationParameters);
CompletableFuture<ExecutionResult> executionResult = parseValidateAndExecute(executionInput, graphQLSchema, instrumentationState);
//
// finish up instrumentation
executionResult = executionResult.whenComplete(executionInstrumentation::onCompleted);
//
// allow instrumentation to tweak the result
executionResult = executionResult.thenCompose(result -> instrumentation.instrumentExecutionResult(result, instrumentationParameters));
executionResult = executionResult.whenComplete((result,throwable) -> {
if (throwable != null) {
beginExecutionCF.completeExceptionally(throwable);
} else {
beginExecutionCF.complete(result);
}
executionInstrumentation.onDispatched(beginExecutionCF);
});
return executionResult;
} catch (AbortExecutionException abortException) {
return CompletableFuture.completedFuture(abortException.toExecutionResult());
}
That is its dispatched IMMEDIATELY and the CF given on that is completed at the end
Can you change your PR and take this code please. This is the right fix
this will change the test below
There was a problem hiding this comment.
Awesome. I'll make the change. Thank you for the quick turn around.
There was a problem hiding this comment.
I can't seem to get the tests to run locally for me (something with the gradle daemon). Could I get approval for this to run the tests? I don't want to move this from draft status until I can successfully test it, of course.
There was a problem hiding this comment.
I tend to run the tests inside IDEA - albeit .gradlew clean build also works for me
I have approved the build and hence the github actions will run the builds
…inExecution - resolves graphql-java#1620
c9cc5ab to
04a944c
Compare
| beginExecutionCF.complete(result); | ||
| } | ||
| executionInstrumentation.onCompleted(result, throwable); | ||
| }); |
There was a problem hiding this comment.
yeah that is better than what I proposed
|
SubscriptionExecutionStrategyTest > instrumentation gets called on subscriptions FAILED Lots of tests that assert instrument test call chain are failing. You really need to work out your local test env to runs tests |
|
Or just keep commiting and allow github to run them |
|
I'll get it running locally. |
|
See #2730 |
|
Thanks for the original PR - I took it and tweaked it a little and fixed the tests |
|
@bbakerman Awesome! thanks so much, sorry that I wasn't able to finish it off faster, I got pulled onto some other things for a bit. |
Added a call to
onDispatchedfor thebeginExecutioninstrumentation context.resolves #1620