Class ConnectionInterceptor

  • All Implemented Interfaces:
    software.amazon.disco.agent.interception.Installable

    public class ConnectionInterceptor
    extends java.lang.Object
    implements software.amazon.disco.agent.interception.Installable
    A class for intercepting methods on the JDBC Connection class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static software.amazon.disco.agent.logging.Logger log  
      static java.lang.String SQL_PREPARE_ORIGIN  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static software.amazon.disco.agent.event.ServiceRequestEvent enter​(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 void exit​(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 a Throwable.
      net.bytebuddy.agent.builder.AgentBuilder install​(net.bytebuddy.agent.builder.AgentBuilder agentBuilder)
      Installs part of the Disco SQL interception library into a Java program.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface software.amazon.disco.agent.interception.Installable

        handleArguments
    • 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
    • Constructor Detail

      • ConnectionInterceptor

        public ConnectionInterceptor()
    • 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 user
        origin - Identifier of the intercepted method, for debugging/logging
        conn - 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 a Throwable. It extracts the created statement and throwable if any and publishes a ServiceDownstreamResponseEvent.
        Parameters:
        requestEvent - the disco event generated when this prepare request was made
        response - the PreparedStatement returned by the Connection
        thrown - the Throwable thrown by the connection, or null if preparation was successful. Typically a SQLException.
      • 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:
        install in interface software.amazon.disco.agent.interception.Installable
        Parameters:
        agentBuilder - - an AgentBuilder to append instructions to
        Returns:
        - the AgentBuilder object for chaining