(
        self,
        check,  # type: AgentCheck
        executor,  # type:  QueryExecutor
        queries=None,  # type: List[Dict[str, Any]]
        tags=None,  # type: List[str]
        error_handler=None,  # type: Callable[[str], str]
        hostname=None,  # type: str
    )
- **check** (_AgentCheck_) - an instance of a Check
        - **executor** (_callable_) - a callable accepting a `str` query as its sole argument and returning
          a sequence representing either the full result set or an iterator over the result set
        - **queries** (_List[Dict]_) - a list of queries in dict format
        - **tags** (_List[str]_) - a list of tags to associate with every submission
        - **error_handler** (_callable_) - a callable accepting a `str` error as its sole argument and returning
          a sanitized string, useful for scrubbing potentially sensitive information libraries emit
- **check** (_AgentCheck_) - an instance of a Check
        - **executor** (_callable_) - a callable accepting a `str` query as its sole argument and returning
          a sequence representing either the full result set or an iterator over the result set
        - **queries** (_List[Dict]_) - a list of queries in dict format
        - **tags** (_List[str]_) - a list of tags to associate with every submission
        - **error_handler** (_callable_) - a callable accepting a `str` error as its sole argument and returning
          a sanitized string, useful for scrubbing potentially sensitive information libraries emit
- ** check ** ( _AgentCheck_ ) - an instance of a Check - ** executor ** ( _callable_ ) - a callable accepting a str query as its sole argument and returning a sequence representing either the full result set or an iterator over the result set - ** queries ** ( _List [ Dict ] _ ) - a list of queries in dict format - ** tags ** ( _List [ str ] _ ) - a list of tags to associate with every submission - ** error_handler ** ( _callable_ ) - a callable accepting a str error as its sole argument and returning a sanitized string useful for scrubbing potentially sensitive information libraries emit
def __init__(
        self,
        check,  # type: AgentCheck
        executor,  # type:  QueryExecutor
        queries=None,  # type: List[Dict[str, Any]]
        tags=None,  # type: List[str]
        error_handler=None,  # type: Callable[[str], str]
        hostname=None,  # type: str
    ):  # type: (...) -> QueryManager
        """
        - **check** (_AgentCheck_) - an instance of a Check
        - **executor** (_callable_) - a callable accepting a `str` query as its sole argument and returning
          a sequence representing either the full result set or an iterator over the result set
        - **queries** (_List[Dict]_) - a list of queries in dict format
        - **tags** (_List[str]_) - a list of tags to associate with every submission
        - **error_handler** (_callable_) - a callable accepting a `str` error as its sole argument and returning
          a sanitized string, useful for scrubbing potentially sensitive information libraries emit
        """
        self.check = check  # type: AgentCheck
        self.executor = executor  # type:  QueryExecutor
        self.tags = tags or []
        self.error_handler = error_handler
        self.queries = [Query(payload) for payload in queries or []]  # type: List[Query]
        self.hostname = hostname  # type: str
        self.logger = self.check.log

        only_custom_queries = is_affirmative(self.check.instance.get('only_custom_queries', False))  # type: bool
        custom_queries = list(self.check.instance.get('custom_queries', []))  # type: List[str]
        use_global_custom_queries = self.check.instance.get('use_global_custom_queries', True)  # type: str

        # Handle overrides
        if use_global_custom_queries == 'extend':
            custom_queries.extend(self.check.init_config.get('global_custom_queries', []))
        elif (
            not custom_queries
            and 'global_custom_queries' in self.check.init_config
            and is_affirmative(use_global_custom_queries)
        ):
            custom_queries = self.check.init_config.get('global_custom_queries', [])

        # Override statement queries if only running custom queries
        if only_custom_queries:
            self.queries = []

        # Deduplicate
        for i, custom_query in enumerate(iter_unique(custom_queries), 1):
            query = Query(custom_query)
            query.query_data.setdefault('name', 'custom query #{}'.format(i))
            self.queries.append(query)

        if len(self.queries) == 0:
            self.logger.warning('QueryManager initialized with no query')
def __init__ ( self , check , # type: AgentCheck executor , # type:  QueryExecutor queries = None , # type: List[Dict[str, Any]] tags = None , # type: List[str] error_handler = None , # type: Callable[[str], str] hostname = None , # type: str ) : # type: (...) -> QueryManager self . check = check # type: AgentCheck self . executor = executor # type:  QueryExecutor self . tags = tags or [ ] self . error_handler = error_handler self . queries = [ Query ( payload ) for payload in queries or [ ] ] # type: List[Query] self . hostname = hostname # type: str self . logger = self . check . log only_custom_queries = is_affirmative ( self . check . instance . get ( 'only_custom_queries' , False ) ) # type: bool custom_queries = list ( self . check . instance . get ( 'custom_queries' , [ ] ) ) # type: List[str] use_global_custom_queries = self . check . instance . get ( 'use_global_custom_queries' , True ) # type: str # Handle overrides if use_global_custom_queries == 'extend' : custom_queries . extend ( self . check . init_config . get ( 'global_custom_queries' , [ ] ) ) elif ( not custom_queries and 'global_custom_queries' in self . check . init_config and is_affirmative ( use_global_custom_queries ) ) : custom_queries = self . check . init_config . get ( 'global_custom_queries' , [ ] ) # Override statement queries if only running custom queries if only_custom_queries : self . queries = [ ] # Deduplicate for i , custom_query in enumerate ( iter_unique ( custom_queries ) , 1 ) : query = Query ( custom_query ) query . query_data . setdefault ( 'name' , 'custom query #{}' . format ( i ) ) self . queries . append ( query ) if len ( self . queries ) == 0 : self . logger . warning ( 'QueryManager initialized with no query' )