public interface QueryObserver
Observes query executions performed by an ORM template.
Query observers are designed to back metrics and tracing bindings, such as Micrometer Observations. They are
configured per ORM template via the template builder; they are deliberately not discovered through the
ServiceLoader mechanism.
Observer failures are contained by the framework and never affect query execution: an exception thrown by an observer is logged and discarded, and the query result or failure is delivered to the caller unchanged.
- Since:
- 1.13
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceTracks a single observed statement execution.static interfaceTracks a single observed physical transaction. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final QueryObserverObserver that ignores all executions. -
Method Summary
Modifier and TypeMethodDescriptionstatic QueryObservernoop()onExecute(QueryContext context) Called when a statement execution starts.onTransaction(TransactionOptions options) Called when a physical transaction opens: an outermost transaction block, or aREQUIRES_NEWblock.
-
Field Details
-
NOOP
Observer that ignores all executions. Exposed as a constant so hot paths can skip context creation with an identity check.
-
-
Method Details
-
onExecute
Called when a statement execution starts.The returned observation is closed exactly once: for updates and batches when execution completes; for result streams when the stream is closed.
- Parameters:
context- describes the statement execution; nevernull.- Returns:
- the observation tracking this execution; never
null.
-
onTransaction
Called when a physical transaction opens: an outermost transaction block, or aREQUIRES_NEWblock. Joined blocks and savepoint scopes are not physical transactions and are not observed.The default implementation ignores transactions.
- Parameters:
options- the options the transaction was opened with; nevernull.- Returns:
- the observation tracking this transaction; never
null. - Since:
- 1.13
-
noop
-