@PublicSpi public interface Instrumentation
For example you might want to track which fields are taking the most time to fetch from the backing database or log what fields are being asked for.
Remember that graphql calls can cross threads so make sure you think about the thread safety of any instrumentation code when you are writing it.
Each step gives back an InstrumentationContext
object. This has two callbacks on it,
one for the step is `dispatched` and one for when the step has `completed`. This is done because many of the "steps" are asynchronous
operations such as fetching data and resolving it into objects.
Modifier and Type | Method and Description |
---|---|
default @NotNull InstrumentationContext<ExecutionResult> |
beginExecuteOperation(InstrumentationExecuteOperationParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<ExecutionResult> |
beginExecuteOperation(InstrumentationExecuteOperationParameters parameters,
InstrumentationState state)
This is called just before the execution of the query operation is started.
|
default @NotNull InstrumentationContext<ExecutionResult> |
beginExecution(InstrumentationExecutionParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<ExecutionResult> |
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.
|
default @NotNull ExecutionStrategyInstrumentationContext |
beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters)
Deprecated.
|
default @Nullable ExecutionStrategyInstrumentationContext |
beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters,
InstrumentationState state)
This is called each time an
ExecutionStrategy is invoked, which may be multiple times
per query as the engine recursively descends down over the query. |
default @NotNull InstrumentationContext<ExecutionResult> |
beginField(InstrumentationFieldParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<ExecutionResult> |
beginField(InstrumentationFieldParameters parameters,
InstrumentationState state)
This is called just before a field is resolved into a value.
|
default @NotNull InstrumentationContext<ExecutionResult> |
beginFieldComplete(InstrumentationFieldCompleteParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<ExecutionResult> |
beginFieldComplete(InstrumentationFieldCompleteParameters parameters,
InstrumentationState state)
This is called just before the complete field is started.
|
default @NotNull InstrumentationContext<java.lang.Object> |
beginFieldFetch(InstrumentationFieldFetchParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<java.lang.Object> |
beginFieldFetch(InstrumentationFieldFetchParameters parameters,
InstrumentationState state)
This is called just before a field
DataFetcher is invoked. |
default @NotNull InstrumentationContext<ExecutionResult> |
beginFieldListComplete(InstrumentationFieldCompleteParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<ExecutionResult> |
beginFieldListComplete(InstrumentationFieldCompleteParameters parameters,
InstrumentationState state)
This is called just before the complete field list is started.
|
default @NotNull InstrumentationContext<Document> |
beginParse(InstrumentationExecutionParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<Document> |
beginParse(InstrumentationExecutionParameters parameters,
InstrumentationState state)
This is called just before a query is parsed.
|
default @NotNull InstrumentationContext<ExecutionResult> |
beginSubscribedFieldEvent(InstrumentationFieldParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<ExecutionResult> |
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.
|
default @NotNull InstrumentationContext<java.util.List<ValidationError>> |
beginValidation(InstrumentationValidationParameters parameters)
Deprecated.
|
default @Nullable InstrumentationContext<java.util.List<ValidationError>> |
beginValidation(InstrumentationValidationParameters parameters,
InstrumentationState state)
This is called just before the parsed query document is validated.
|
default InstrumentationState |
createState()
Deprecated.
|
default @Nullable InstrumentationState |
createState(InstrumentationCreateStateParameters parameters)
This will be called just before execution to create an object that is given back to all instrumentation methods
to allow them to have per execution request state
|
default @NotNull DataFetcher<?> |
instrumentDataFetcher(DataFetcher<?> dataFetcher,
InstrumentationFieldFetchParameters parameters)
Deprecated.
|
default @NotNull DataFetcher<?> |
instrumentDataFetcher(DataFetcher<?> dataFetcher,
InstrumentationFieldFetchParameters parameters,
InstrumentationState state)
This is called to instrument a
DataFetcher just before it is used to fetch a field, allowing you
to adjust what information is passed back or record information about specific data fetches. |
default @NotNull DocumentAndVariables |
instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables,
InstrumentationExecutionParameters parameters)
|
default @NotNull DocumentAndVariables |
instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables,
InstrumentationExecutionParameters parameters,
InstrumentationState state)
This is called to instrument a
Document and variables before it is used allowing you to adjust the query AST if you so desire |
default @NotNull ExecutionContext |
instrumentExecutionContext(ExecutionContext executionContext,
InstrumentationExecutionParameters parameters)
|
default @NotNull ExecutionContext |
instrumentExecutionContext(ExecutionContext executionContext,
InstrumentationExecutionParameters parameters,
InstrumentationState state)
This is called to instrument a
ExecutionContext before it is used to execute a query,
allowing you to adjust the base data used. |
default @NotNull ExecutionInput |
instrumentExecutionInput(ExecutionInput executionInput,
InstrumentationExecutionParameters parameters)
|
default @NotNull ExecutionInput |
instrumentExecutionInput(ExecutionInput executionInput,
InstrumentationExecutionParameters parameters,
InstrumentationState state)
This is called to instrument a
ExecutionInput before it is used to parse, validate
and execute a query, allowing you to adjust what query input parameters are used |
default @NotNull java.util.concurrent.CompletableFuture<ExecutionResult> |
instrumentExecutionResult(ExecutionResult executionResult,
InstrumentationExecutionParameters parameters)
|
default @NotNull java.util.concurrent.CompletableFuture<ExecutionResult> |
instrumentExecutionResult(ExecutionResult executionResult,
InstrumentationExecutionParameters parameters,
InstrumentationState state)
This is called to allow instrumentation to instrument the execution result in some way
|
default @NotNull GraphQLSchema |
instrumentSchema(GraphQLSchema schema,
InstrumentationExecutionParameters parameters)
Deprecated.
|
default @NotNull GraphQLSchema |
instrumentSchema(GraphQLSchema schema,
InstrumentationExecutionParameters parameters,
InstrumentationState state)
This is called to instrument a
GraphQLSchema before it is used to parse, validate
and execute a query, allowing you to adjust what types are used. |
@Deprecated default InstrumentationState createState()
createState(InstrumentationCreateStateParameters)
instead@Nullable default @Nullable InstrumentationState createState(InstrumentationCreateStateParameters parameters)
parameters
- the parameters to this step@Deprecated @NotNull default @NotNull InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters)
beginExecution(InstrumentationExecutionParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters)
beginParse(InstrumentationExecutionParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<Document> beginParse(InstrumentationExecutionParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<java.util.List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters)
beginValidation(InstrumentationValidationParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<java.util.List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters)
beginExecuteOperation(InstrumentationExecuteOperationParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters)
beginExecutionStrategy(InstrumentationExecutionStrategyParameters, InstrumentationState)
insteadExecutionStrategy
is invoked, which may be multiple times
per query as the engine recursively descends down over the query.parameters
- the parameters to this stepExecutionStrategyInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable ExecutionStrategyInstrumentationContext beginExecutionStrategy(InstrumentationExecutionStrategyParameters parameters, InstrumentationState state)
ExecutionStrategy
is invoked, which may be multiple times
per query as the engine recursively descends down over the query.parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
ExecutionStrategyInstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters)
beginSubscribedFieldEvent(InstrumentationFieldParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<ExecutionResult> beginSubscribedFieldEvent(InstrumentationFieldParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<ExecutionResult> beginField(InstrumentationFieldParameters parameters)
beginField(InstrumentationFieldParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<ExecutionResult> beginField(InstrumentationFieldParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<java.lang.Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters)
beginFieldFetch(InstrumentationFieldFetchParameters, InstrumentationState)
insteadDataFetcher
is invoked.parameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<java.lang.Object> beginFieldFetch(InstrumentationFieldFetchParameters parameters, InstrumentationState state)
DataFetcher
is invoked.parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<ExecutionResult> beginFieldComplete(InstrumentationFieldCompleteParameters parameters)
beginFieldComplete(InstrumentationFieldCompleteParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<ExecutionResult> beginFieldComplete(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull InstrumentationContext<ExecutionResult> beginFieldListComplete(InstrumentationFieldCompleteParameters parameters)
beginFieldListComplete(InstrumentationFieldCompleteParameters, InstrumentationState)
insteadparameters
- the parameters to this stepInstrumentationContext
object that will be called back when the step ends@Nullable default @Nullable InstrumentationContext<ExecutionResult> beginFieldListComplete(InstrumentationFieldCompleteParameters parameters, InstrumentationState state)
parameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
InstrumentationContext
object that will be called back when the step ends (assuming it's not null)@Deprecated @NotNull default @NotNull ExecutionInput instrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters)
instrumentExecutionInput(ExecutionInput, InstrumentationExecutionParameters, InstrumentationState)
insteadExecutionInput
before it is used to parse, validate
and execute a query, allowing you to adjust what query input parameters are usedexecutionInput
- the execution input to be usedparameters
- the parameters describing the field to be fetched@NotNull default @NotNull ExecutionInput instrumentExecutionInput(ExecutionInput executionInput, InstrumentationExecutionParameters parameters, InstrumentationState state)
ExecutionInput
before it is used to parse, validate
and execute a query, allowing you to adjust what query input parameters are usedexecutionInput
- the execution input to be usedparameters
- the parameters describing the field to be fetchedstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
@Deprecated @NotNull default @NotNull DocumentAndVariables instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters)
instrumentDocumentAndVariables(DocumentAndVariables, InstrumentationExecutionParameters, InstrumentationState)
insteadDocument
and variables before it is used allowing you to adjust the query AST if you so desiredocumentAndVariables
- the document and variables to be usedparameters
- the parameters describing the execution@NotNull default @NotNull DocumentAndVariables instrumentDocumentAndVariables(DocumentAndVariables documentAndVariables, InstrumentationExecutionParameters parameters, InstrumentationState state)
Document
and variables before it is used allowing you to adjust the query AST if you so desiredocumentAndVariables
- the document and variables to be usedparameters
- the parameters describing the executionstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
@Deprecated @NotNull default @NotNull GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters)
instrumentSchema(GraphQLSchema, InstrumentationExecutionParameters, InstrumentationState)
insteadGraphQLSchema
before it is used to parse, validate
and execute a query, allowing you to adjust what types are used.schema
- the schema to be usedparameters
- the parameters describing the field to be fetched@NotNull default @NotNull GraphQLSchema instrumentSchema(GraphQLSchema schema, InstrumentationExecutionParameters parameters, InstrumentationState state)
GraphQLSchema
before it is used to parse, validate
and execute a query, allowing you to adjust what types are used.schema
- the schema to be usedparameters
- the parameters describing the field to be fetchedstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
@Deprecated @NotNull default @NotNull ExecutionContext instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters)
instrumentExecutionContext(ExecutionContext, InstrumentationExecutionParameters, InstrumentationState)
insteadExecutionContext
before it is used to execute a query,
allowing you to adjust the base data used.executionContext
- the execution context to be usedparameters
- the parameters describing the field to be fetched@NotNull default @NotNull ExecutionContext instrumentExecutionContext(ExecutionContext executionContext, InstrumentationExecutionParameters parameters, InstrumentationState state)
ExecutionContext
before it is used to execute a query,
allowing you to adjust the base data used.executionContext
- the execution context to be usedparameters
- the parameters describing the field to be fetchedstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
@Deprecated @NotNull default @NotNull DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters)
instrumentDataFetcher(DataFetcher, InstrumentationFieldFetchParameters, InstrumentationState)
insteadDataFetcher
just before it is used to fetch a field, allowing you
to adjust what information is passed back or record information about specific data fetches. Note
the same data fetcher instance maybe presented to you many times and that data fetcher
implementations widely vary.dataFetcher
- the data fetcher about to be usedparameters
- the parameters describing the field to be fetched@NotNull default @NotNull DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher, InstrumentationFieldFetchParameters parameters, InstrumentationState state)
DataFetcher
just before it is used to fetch a field, allowing you
to adjust what information is passed back or record information about specific data fetches. Note
the same data fetcher instance maybe presented to you many times and that data fetcher
implementations widely vary.dataFetcher
- the data fetcher about to be usedparameters
- the parameters describing the field to be fetchedstate
- the state created during the call to createState(InstrumentationCreateStateParameters)
@Deprecated @NotNull default @NotNull java.util.concurrent.CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters)
instrumentExecutionResult(ExecutionResult, InstrumentationExecutionParameters, InstrumentationState)
insteadexecutionResult
- CompletableFuture
of the result to instrumentparameters
- the parameters to this step@NotNull default @NotNull java.util.concurrent.CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState state)
executionResult
- CompletableFuture
of the result to instrumentparameters
- the parameters to this stepstate
- the state created during the call to createState(InstrumentationCreateStateParameters)