(self, extra_tags=None)
This method is what you call every check run.
This method is what you call every check run.
This method is what you call every check run .
def execute(self, extra_tags=None):
        """This method is what you call every check run."""
        # This needs to stay here b/c when we construct a QueryManager in a check's __init__
        # there is no check ID at that point
        self.logger = self.check.log

        global_tags = list(self.tags)
        if extra_tags:
            global_tags.extend(list(extra_tags))

        for query in self.queries:
            query_name = query.name
            query_columns = query.column_transformers
            extra_transformers = query.extra_transformers
            query_tags = query.base_tags

            try:
                rows = self.execute_query(query.query)
            except Exception as e:
                if self.error_handler:
                    self.logger.error('Error querying %s: %s', query_name, self.error_handler(str(e)))
                else:
                    self.logger.error('Error querying %s: %s', query_name, e)

                continue

            for row in rows:
                if not self._is_row_valid(query, row):
                    continue

                # It holds the query results
                sources = {}  # type: Dict[str, str]
                # It holds the transformers defined in query_columns along with the column value
                submission_queue = []  # type: List[Tuple[Transformer, Any]]
                tags = global_tags + query_tags

                for (column_name, type_transformer), column_value in zip(query_columns, row):
                    # Columns can be ignored via configuration
                    if not column_name:
                        continue

                    sources[column_name] = column_value
                    column_type, transformer = type_transformer

                    # The transformer can be None for `source` types. Those such columns do not submit
                    # anything but are collected into the row values for other columns to reference.
                    if transformer is None:
                        continue
                    elif column_type == 'tag':
                        tags.append(transformer(None, column_value))  # get_tag transformer
                    elif column_type == 'tag_list':
                        tags.extend(transformer(None, column_value))  # get_tag_list transformer
                    else:
                        submission_queue.append((transformer, column_value))

                for transformer, value in submission_queue:
                    transformer(sources, value, tags=tags, hostname=self.hostname)

                for name, transformer in extra_transformers:
                    try:
                        result = transformer(sources, tags=tags, hostname=self.hostname)
                    except Exception as e:
                        self.logger.error('Error transforming %s: %s', name, e)
                        continue
                    else:
                        if result is not None:
                            sources[name] = result
def execute ( self , extra_tags = None ) : # This needs to stay here b/c when we construct a QueryManager in a check's __init__ # there is no check ID at that point self . logger = self . check . log global_tags = list ( self . tags ) if extra_tags : global_tags . extend ( list ( extra_tags ) ) for query in self . queries : query_name = query . name query_columns = query . column_transformers extra_transformers = query . extra_transformers query_tags = query . base_tags try : rows = self . execute_query ( query . query ) except Exception as e : if self . error_handler : self . logger . error ( 'Error querying %s: %s' , query_name , self . error_handler ( str ( e ) ) ) else : self . logger . error ( 'Error querying %s: %s' , query_name , e ) continue for row in rows : if not self . _is_row_valid ( query , row ) : continue # It holds the query results sources = { } # type: Dict[str, str] # It holds the transformers defined in query_columns along with the column value submission_queue = [ ] # type: List[Tuple[Transformer, Any]] tags = global_tags + query_tags for ( column_name , type_transformer ) , column_value in zip ( query_columns , row ) : # Columns can be ignored via configuration if not column_name : continue sources [ column_name ] = column_value column_type , transformer = type_transformer # The transformer can be None for `source` types. Those such columns do not submit # anything but are collected into the row values for other columns to reference. if transformer is None : continue elif column_type == 'tag' : tags . append ( transformer ( None , column_value ) ) # get_tag transformer elif column_type == 'tag_list' : tags . extend ( transformer ( None , column_value ) ) # get_tag_list transformer else : submission_queue . append ( ( transformer , column_value ) ) for transformer , value in submission_queue : transformer ( sources , value , tags = tags , hostname = self . hostname ) for name , transformer in extra_transformers : try : result = transformer ( sources , tags = tags , hostname = self . hostname ) except Exception as e : self . logger . error ( 'Error transforming %s: %s' , name , e ) continue else : if result is not None : sources [ name ] = result