Package software.amazon.disco.agent.sql
Class ConnectionInterceptor
- java.lang.Object
-
- software.amazon.disco.agent.sql.ConnectionInterceptor
-
- All Implemented Interfaces:
software.amazon.disco.agent.interception.Installable
public class ConnectionInterceptor extends java.lang.Object implements software.amazon.disco.agent.interception.InstallableA class for intercepting methods on the JDBC Connection class.
-
-
Field Summary
Fields Modifier and Type Field Description static software.amazon.disco.agent.logging.Loggerlogstatic java.lang.StringSQL_PREPARE_ORIGIN
-
Constructor Summary
Constructors Constructor Description ConnectionInterceptor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static software.amazon.disco.agent.event.ServiceRequestEvententer(java.lang.String queryString, java.lang.String origin, java.sql.Connection conn)This method is inlined before any calls to prepareStatement or prepareCall, and its purpose is to capture the query string provided as the first argument.static voidexit(software.amazon.disco.agent.event.ServiceRequestEvent requestEvent, java.sql.PreparedStatement response, java.lang.Throwable thrown)This method is inlined with a preparation method at the moment it would return or throw aThrowable.net.bytebuddy.agent.builder.AgentBuilderinstall(net.bytebuddy.agent.builder.AgentBuilder agentBuilder)Installs part of the Disco SQL interception library into a Java program.
-
-
-
Field Detail
-
log
public static final software.amazon.disco.agent.logging.Logger log
-
SQL_PREPARE_ORIGIN
public static final java.lang.String SQL_PREPARE_ORIGIN
- See Also:
- Constant Field Values
-
-
Method Detail
-
enter
@OnMethodEnter public static software.amazon.disco.agent.event.ServiceRequestEvent enter(@Argument(0) java.lang.String queryString, @Origin java.lang.String origin, @This java.sql.Connection conn)This method is inlined before any calls to prepareStatement or prepareCall, and its purpose is to capture the query string provided as the first argument.- Parameters:
queryString- The (potentially parameterized) query string provided by userorigin- Identifier of the intercepted method, for debugging/loggingconn- Connection object being used to prepare the statement/call- Returns:
- The generated disco
ServiceDownstreamRequestEvent, with fields filled out on a best-effort basis, including the Connection as the request object.
-
exit
@OnMethodExit(onThrowable=java.lang.Throwable.class) public static void exit(@Enter software.amazon.disco.agent.event.ServiceRequestEvent requestEvent, @Return java.sql.PreparedStatement response, @Thrown java.lang.Throwable thrown)This method is inlined with a preparation method at the moment it would return or throw aThrowable. It extracts the created statement and throwable if any and publishes aServiceDownstreamResponseEvent.- Parameters:
requestEvent- the disco event generated when this prepare request was maderesponse- thePreparedStatementreturned by theConnectionthrown- the Throwable thrown by the connection, or null if preparation was successful. Typically aSQLException.
-
install
public net.bytebuddy.agent.builder.AgentBuilder install(net.bytebuddy.agent.builder.AgentBuilder agentBuilder)
Installs part of the Disco SQL interception library into a Java program. Intended to be invoked during an agent's premain.- Specified by:
installin interfacesoftware.amazon.disco.agent.interception.Installable- Parameters:
agentBuilder- - an AgentBuilder to append instructions to- Returns:
- - the
AgentBuilderobject for chaining
-
-