예제 #1
0
    def test_unwrap_connect(self, mock_dbapi):
        dbapi.wrap_connect(self.tracer, mock_dbapi, "connect", "-")
        connection = mock_dbapi.connect()
        self.assertEqual(mock_dbapi.connect.call_count, 1)

        dbapi.unwrap_connect(mock_dbapi, "connect")
        connection = mock_dbapi.connect()
        self.assertEqual(mock_dbapi.connect.call_count, 2)
        self.assertIsInstance(connection, mock.Mock)
예제 #2
0
    def _instrument(self, **kwargs):
        """Integrate with the PyMySQL library.
        https://github.com/PyMySQL/PyMySQL/
        """
        tracer_provider = kwargs.get("tracer_provider")

        tracer = get_tracer(__name__, __version__, tracer_provider)

        dbapi.wrap_connect(
            tracer,
            pymysql,
            "connect",
            self._DATABASE_COMPONENT,
            self._DATABASE_TYPE,
            self._CONNECTION_ATTRIBUTES,
        )
예제 #3
0
    def _instrument(self, **kwargs):
        """Integrate with MySQL Connector/Python library.
        https://dev.mysql.com/doc/connector-python/en/
        """
        tracer_provider = kwargs.get("tracer_provider")

        tracer = get_tracer(__name__, __version__, tracer_provider)

        dbapi.wrap_connect(
            tracer,
            mysql.connector,
            "connect",
            self._DATABASE_COMPONENT,
            self._DATABASE_TYPE,
            self._CONNECTION_ATTRIBUTES,
        )
예제 #4
0
    def _instrument(self, **kwargs):
        """Integrate with the PyMySQL library.
        https://github.com/PyMySQL/PyMySQL/
        """
        tracer_provider = kwargs.get("tracer_provider")

        tracer = get_tracer(__name__, __version__, tracer_provider)

        connection_attributes = {
            "database": "db",
            "port": "port",
            "host": "host",
            "user": "******",
        }
        wrap_connect(tracer, pymysql, "connect", "mysql", "sql",
                     connection_attributes)
예제 #5
0
def trace_integration(tracer_provider: typing.Optional[TracerProvider] = None):
    """Integrate with the PyMySQL library.
       https://github.com/PyMySQL/PyMySQL/
    """

    tracer = get_tracer(__name__, __version__, tracer_provider)

    connection_attributes = {
        "database": "db",
        "port": "port",
        "host": "host",
        "user": "******",
    }
    wrap_connect(
        tracer, pymysql, "connect", "mysql", "sql", connection_attributes
    )
예제 #6
0
    def _instrument(self, **kwargs):
        """Integrate with SQLite3 Python library.
        https://docs.python.org/3/library/sqlite3.html
        """
        tracer_provider = kwargs.get("tracer_provider")

        dbapi.wrap_connect(
            __name__,
            sqlite3,
            "connect",
            self._DATABASE_COMPONENT,
            self._DATABASE_TYPE,
            self._CONNECTION_ATTRIBUTES,
            version=__version__,
            tracer_provider=tracer_provider,
        )
예제 #7
0
    def _instrument(self, **kwargs):
        """Integrate with PostgreSQL Psycopg library.
           Psycopg: http://initd.org/psycopg/
        """

        tracer_provider = kwargs.get("tracer_provider")

        tracer = get_tracer(__name__, __version__, tracer_provider)

        dbapi.wrap_connect(
            tracer,
            psycopg2,
            "connect",
            self._DATABASE_COMPONENT,
            self._DATABASE_TYPE,
            self._CONNECTION_ATTRIBUTES,
        )
예제 #8
0
def trace_integration(tracer_provider: typing.Optional[TracerProvider] = None):
    """Integrate with MySQL Connector/Python library.
       https://dev.mysql.com/doc/connector-python/en/
    """

    tracer = get_tracer(__name__, __version__, tracer_provider)

    connection_attributes = {
        "database": "database",
        "port": "server_port",
        "host": "server_host",
        "user": "******",
    }
    wrap_connect(
        tracer,
        mysql.connector,
        "connect",
        "mysql",
        "sql",
        connection_attributes,
    )
 def test_wrap_connect(self, mock_dbapi):
     dbapi.wrap_connect(self.tracer, mock_dbapi, "connect", "-")
     connection = mock_dbapi.connect()
     self.assertEqual(mock_dbapi.connect.call_count, 1)
     self.assertIsInstance(connection, dbapi.TracedConnectionProxy)
     self.assertIsInstance(connection.__wrapped__, mock.Mock)