Module com.microsoft.sqlserver.jdbc
Package com.microsoft.sqlserver.jdbc
Interface PerformanceLogCallback
-
public interface PerformanceLogCallbackCallback interface for publishing performance logs. Thedurationparameter inpublish(PerformanceActivity, int, long, Exception)andpublish(PerformanceActivity, int, int, long, Exception)contains the operation duration in milliseconds by default. To receive nanosecond granularity instead, overrideuseNanoseconds()to returntrue.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default StringgetCurrentApplicationName()Returns the application name of the connection associated with the current performance event.default StatementTypegetCurrentStatementType()Returns the statement type for the current performance event.default StringgetCurrentUserSql()Returns the SQL text for the current performance event.voidpublish(PerformanceActivity activity, int connectionId, int statementId, long duration, Exception exception)Publish performance log for statement-level activities.voidpublish(PerformanceActivity activity, int connectionId, long duration, Exception exception)Publish performance log for connection-level activities.default booleanuseNanoseconds()Indicates whether the callback wants duration values in nanoseconds.
-
-
-
Method Detail
-
publish
void publish(PerformanceActivity activity, int connectionId, long duration, Exception exception) throws Exception
Publish performance log for connection-level activities.- Parameters:
activity- The type of activity being logged.connectionId- The ID of the connection.duration- The duration of the operation (milliseconds by default, nanoseconds ifuseNanoseconds()returns true).exception- An exception, if an error occurred.- Throws:
Exception- if the callback cannot publish the performance event.
-
publish
void publish(PerformanceActivity activity, int connectionId, int statementId, long duration, Exception exception) throws Exception
Publish performance log for statement-level activities.- Parameters:
activity- The type of activity being logged.connectionId- The ID of the connection.statementId- The ID of the statement (if applicable).duration- The duration of the operation (milliseconds by default, nanoseconds ifuseNanoseconds()returns true).exception- An exception, if an error occurred.- Throws:
Exception- if the callback cannot publish the performance event.
-
useNanoseconds
default boolean useNanoseconds()
Indicates whether the callback wants duration values in nanoseconds. Override this method to returntrueto receive nanosecond granularity in thedurationparameter ofpublish(PerformanceActivity, int, long, Exception)andpublish(PerformanceActivity, int, int, long, Exception). The default isfalse(milliseconds).- Returns:
- true if duration should be reported in nanoseconds, false for milliseconds.
-
getCurrentUserSql
default String getCurrentUserSql()
Returns the SQL text for the current performance event. Only valid inside apublish(com.microsoft.sqlserver.jdbc.PerformanceActivity, int, long, java.lang.Exception)callback invocation. Returnsnullfor connection-level activities or when called outsidepublish().- Returns:
- the user SQL text, or null if not available.
-
getCurrentStatementType
default StatementType getCurrentStatementType()
Returns the statement type for the current performance event. Only valid inside apublish(com.microsoft.sqlserver.jdbc.PerformanceActivity, int, long, java.lang.Exception)callback invocation. Returnsnullfor connection-level activities or when called outsidepublish().- Returns:
- the
StatementType, or null if not applicable.
-
getCurrentApplicationName
default String getCurrentApplicationName()
Returns the application name of the connection associated with the current performance event. This is the value of theapplicationNameconnection property, which defaults to "Microsoft JDBC Driver for SQL Server" when not set. Applications using a connection pool can set this property on the pool's data source to identify which pool the event originated from. UnlikegetCurrentUserSql(), this value is available for both connection-level and statement-level activities. Only valid inside apublish(com.microsoft.sqlserver.jdbc.PerformanceActivity, int, long, java.lang.Exception)callback invocation. Returnsnullwhen called outsidepublish(), or when the connection properties have not been parsed yet (for example, a connection that fails before the property is resolved).- Returns:
- the application name, or null if not available.
-
-