(self)
Collects all current activity for the SQLServer intance.
        :return:
Collects all current activity for the SQLServer intance.
        :return:
Collects all current activity for the SQLServer intance . : return :
def collect_activity(self):
        """
        Collects all current activity for the SQLServer intance.
        :return:
        """

        # re-use the check's conn module, but set extra_key=dbm-activity- to ensure we get our own
        # raw connection. adodbapi and pyodbc modules are thread safe, but connections are not.
        with self.check.connection.open_managed_default_connection(key_prefix=self._conn_key_prefix):
            with self.check.connection.get_managed_cursor(key_prefix=self._conn_key_prefix) as cursor:
                connections = self._get_active_connections(cursor)
                rows = self._get_activity(cursor)
                normalized_rows = self._normalize_queries_and_filter_rows(rows, MAX_PAYLOAD_BYTES)
                event = self._create_activity_event(normalized_rows, connections)
                payload = json.dumps(event, default=default_json_event_encoding)
                self._check.database_monitoring_query_activity(payload)

        self.check.histogram(
            "dd.sqlserver.activity.collect_activity.payload_size", len(payload), **self.check.debug_stats_kwargs()
        )
def collect_activity ( self ) : # re-use the check's conn module, but set extra_key=dbm-activity- to ensure we get our own # raw connection. adodbapi and pyodbc modules are thread safe, but connections are not. with self . check . connection . open_managed_default_connection ( key_prefix = self . _conn_key_prefix ) : with self . check . connection . get_managed_cursor ( key_prefix = self . _conn_key_prefix ) as cursor : connections = self . _get_active_connections ( cursor ) rows = self . _get_activity ( cursor ) normalized_rows = self . _normalize_queries_and_filter_rows ( rows , MAX_PAYLOAD_BYTES ) event = self . _create_activity_event ( normalized_rows , connections ) payload = json . dumps ( event , default = default_json_event_encoding ) self . _check . database_monitoring_query_activity ( payload ) self . check . histogram ( "dd.sqlserver.activity.collect_activity.payload_size" , len ( payload ) , * * self . check . debug_stats_kwargs ( ) )