QueryObserver.
The operation(), dataType() and kind() properties are low-cardinality and suitable
as metric tags. The statement() property is high-cardinality and is intended for trace attributes only;
it must never be used as a metric tag.
- Since:
- 1.13
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumClassifies how a statement is executed. -
Method Summary
Modifier and TypeMethodDescriptionReturns the number of statements in the batch.dataType()Returns the entity or projection type primarily targeted by the statement.kind()Returns how the statement is executed.Classifies the kind of SQL statement being executed.default StatementOriginorigin()Returns what caused the statement to execute.default longshapeId()Returns the identity of the statement's shape: the template it was generated from, before values were bound.Returns the SQL statement being executed, with all parameters replaced by placeholders.
-
Method Details
-
operation
SqlOperation operation()Classifies the kind of SQL statement being executed.- Returns:
- the SQL operation;
SqlOperation.UNDEFINEDwhen the operation is unknown.
-
dataType
Returns the entity or projection type primarily targeted by the statement.- Returns:
- the data type, or empty when the statement is not associated with a specific type.
-
kind
QueryContext.ExecutionKind kind()Returns how the statement is executed.- Returns:
- the execution kind.
-
origin
Returns what caused the statement to execute.A statement resolving a reference is shaped exactly like a primary key lookup the application could have written itself, so this is what makes the cost of resolving references measurable on its own.
- Returns:
- the statement origin;
StatementOrigin.DIRECTunless the statement resolves a reference.
-
shapeId
default long shapeId()Returns the identity of the statement's shape: the template it was generated from, before values were bound.Statements generated from one template share a shape whatever their parameters look like, including a collection parameter that expands to a different number of placeholders per execution. Grouping by shape therefore treats those as one statement, where the text would split them.
- Returns:
- the shape identity;
0when unknown.
-
batchSize
OptionalInt batchSize()Returns the number of statements in the batch.- Returns:
- the batch size; present only for
QueryContext.ExecutionKind.BATCHexecutions when the size is known at execution time.
-
statement
Returns the SQL statement being executed, with all parameters replaced by placeholders.Note: this value is high-cardinality; use it for trace attributes only, never as a metric tag.
- Returns:
- the SQL statement, or empty when no statement text is available.
-