Class NoContextChainedInstrumentation
java.lang.Object
graphql.execution.instrumentation.ChainedInstrumentation
graphql.execution.instrumentation.NoContextChainedInstrumentation
- All Implemented Interfaces:
Instrumentation
This version of
ChainedInstrumentation will call a list of Instrumentations
but it will never back on the returned InstrumentationContext objects, hence it is only suitable to
certain use cases.
Only use this class if you are optimising for memory usage as scale. In most cases the ChainedInstrumentation
will do the job required with all the instrumentation features used however some users require the fastest performance and lowest memory
usage at scale and this class can be used.
At scale, the fact that the graphql engine holds the InstrumentationContext objects in memory for a (relatively) long time
(the length of the request or the length of a large field fetch) means that memory pressure can grow
and objects move into longer tenure GC pools. Holding these contexts is also not necessary if the instrumentation never needs to know when a
certain execution step finishes.
The InstrumentationContext is used ot know when an execution step has completed, so instrumentations that do
timings say need to use this callback mechanism. Putting such an instrumentation into NoContextChainedInstrumentation would
be a mistake because no callback will occur. Therefore, use of this class is reserved for very specific us cases. You are fore-warned.
This class never holds onto the returned InstrumentationContext objects and always returns null
as itself.-
Field Summary
Fields inherited from class graphql.execution.instrumentation.ChainedInstrumentation
instrumentations -
Constructor Summary
ConstructorsConstructorDescriptionNoContextChainedInstrumentation(Instrumentation... instrumentations) NoContextChainedInstrumentation(List<Instrumentation> instrumentations) -
Method Summary
Modifier and TypeMethodDescriptionbeginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) This is called just before a deferred field is resolved into a value.@Nullable ExecuteObjectInstrumentationContextbeginExecuteObject(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state) This is called each time anExecutionStrategyobject resolution is called, which may be multiple times per query as the engine recursively descends over the query.beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state) This is called just before the execution of the query operation is started.beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state) This is called right at the start of query execution, and it's the first step in the instrumentation chain.beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state) This is called each time anExecutionStrategyis invoked, which may be multiple times per query as the engine recursively descends over the query.@Nullable InstrumentationContext<Object> beginFieldCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) This is called just before the complete field is started.@Nullable InstrumentationContext<Object> beginFieldExecution(InstrumentationFieldParameters parameters, InstrumentationState state) This is called just before a field is resolved into a value.beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state) This is called just before a fieldDataFetcheris invoked.beginFieldFetching(InstrumentationFieldFetchParameters parameters, InstrumentationState state) This is called just before a fieldDataFetcheris invoked.@Nullable InstrumentationContext<Object> beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) This is called just before the complete field list is started.beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state) This is called just before a query is parsed.@Nullable InstrumentationContext<Void> beginReactiveResults(InstrumentationReactiveResultsParameters parameters, InstrumentationState state) This is called just before the execution of any reactive results, namely incremental deferred results or subscriptions.beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state) This is called each time a subscription field produces a new reactive stream event value and it needs to be mapped over via the graphql field subselection.beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state) This is called just before the parsed query document is validated.Methods inherited from class graphql.execution.instrumentation.ChainedInstrumentation
chainedConsume, chainedMapAndDropNulls, createStateAsync, getInstrumentations, instrumentDataFetcher, instrumentDocumentAndVariables, instrumentExecutionContext, instrumentExecutionInput, instrumentExecutionResult, instrumentSchemaMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface graphql.execution.instrumentation.Instrumentation
createState
-
Constructor Details
-
NoContextChainedInstrumentation
-
NoContextChainedInstrumentation
-
-
Method Details
-
beginExecution
public InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called right at the start of query execution, and it's the first step in the instrumentation chain.- Specified by:
beginExecutionin interfaceInstrumentation- Overrides:
beginExecutionin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginParse
public InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before a query is parsed.- Specified by:
beginParsein interfaceInstrumentation- Overrides:
beginParsein classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginValidation
public InstrumentationContext<List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before the parsed query document is validated.- Specified by:
beginValidationin interfaceInstrumentation- Overrides:
beginValidationin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginExecuteOperation
public InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before the execution of the query operation is started.- Specified by:
beginExecuteOperationin interfaceInstrumentation- Overrides:
beginExecuteOperationin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginReactiveResults
public @Nullable InstrumentationContext<Void> beginReactiveResults(InstrumentationReactiveResultsParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before the execution of any reactive results, namely incremental deferred results or subscriptions. When thePublisherfinally ends (with either aThrowableor none) then theInstrumentationContextwil be called back to say the reactive results have finished.- Specified by:
beginReactiveResultsin interfaceInstrumentation- Overrides:
beginReactiveResultsin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginExecutionStrategy
public ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called each time anExecutionStrategyis invoked, which may be multiple times per query as the engine recursively descends over the query.- Specified by:
beginExecutionStrategyin interfaceInstrumentation- Overrides:
beginExecutionStrategyin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
ExecutionStrategyInstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginExecuteObject
public @Nullable ExecuteObjectInstrumentationContext beginExecuteObject(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called each time anExecutionStrategyobject resolution is called, which may be multiple times per query as the engine recursively descends over the query.- Specified by:
beginExecuteObjectin interfaceInstrumentation- Overrides:
beginExecuteObjectin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
ExecutionStrategyInstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginDeferredField
public InstrumentationContext<Object> beginDeferredField(InstrumentationFieldParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before a deferred field is resolved into a value.This is an EXPERIMENTAL instrumentation callback. The method signature will definitely change.
- Specified by:
beginDeferredFieldin interfaceInstrumentation- Overrides:
beginDeferredFieldin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginSubscribedFieldEvent
public InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called each time a subscription field produces a new reactive stream event value and it needs to be mapped over via the graphql field subselection.- Specified by:
beginSubscribedFieldEventin interfaceInstrumentation- Overrides:
beginSubscribedFieldEventin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldExecution
public @Nullable InstrumentationContext<Object> beginFieldExecution(InstrumentationFieldParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before a field is resolved into a value.- Specified by:
beginFieldExecutionin interfaceInstrumentation- Overrides:
beginFieldExecutionin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldFetch
public InstrumentationContext<Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before a fieldDataFetcheris invoked.- Specified by:
beginFieldFetchin interfaceInstrumentation- Overrides:
beginFieldFetchin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldFetching
public FieldFetchingInstrumentationContext beginFieldFetching(InstrumentationFieldFetchParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before a fieldDataFetcheris invoked. TheFieldFetchingInstrumentationContext.onFetchedValue(Object)callback will be invoked once a value is returned by aDataFetcherbut perhaps before its value is completed if it's aCompletableFuturevalue.This method is the replacement method for the now deprecated
Instrumentation.beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)method, and it should be implemented in newInstrumentationclasses. This default version of this method calls back to the deprecatedInstrumentation.beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)method so that older implementations continue to work.- Specified by:
beginFieldFetchingin interfaceInstrumentation- Overrides:
beginFieldFetchingin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldCompletion
public @Nullable InstrumentationContext<Object> beginFieldCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before the complete field is started.- Specified by:
beginFieldCompletionin interfaceInstrumentation- Overrides:
beginFieldCompletionin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-
beginFieldListCompletion
public @Nullable InstrumentationContext<Object> beginFieldListCompletion(InstrumentationFieldCompleteParameters parameters, InstrumentationState state) Description copied from interface:InstrumentationThis is called just before the complete field list is started.- Specified by:
beginFieldListCompletionin interfaceInstrumentation- Overrides:
beginFieldListCompletionin classChainedInstrumentation- Parameters:
parameters- the parameters to this stepstate- the state created during the call toInstrumentation.createStateAsync(InstrumentationCreateStateParameters)- Returns:
- a nullable
InstrumentationContextobject that will be called back when the step ends (assuming it's not null)
-