(metrics, resolver, logger, bulk_threshold=0)
return {'oids': oids, 'next_oids': next_oids, 'bulk_oids': bulk_oids, 'parsed_metrics': parsed_metrics}
Parse the `metrics` section of a config file, and return OIDs to fetch and metrics to submit.
Parse the `metrics` section of a config file, and return OIDs to fetch and metrics to submit.
Parse the metrics section of a config file and return OIDs to fetch and metrics to submit .
def parse_metrics(metrics, resolver, logger, bulk_threshold=0):
    # type: (List[Metric], OIDResolver, Optional[Logger], int) -> ParseMetricsResult
    """
    Parse the `metrics` section of a config file, and return OIDs to fetch and metrics to submit.
    """
    oids = []
    next_oids = []
    bulk_oids = []
    parsed_metrics = []  # type: List[ParsedMetric]

    for metric in metrics:
        result = _parse_metric(metric, logger)

        for oid in result.oids_to_fetch:
            oids.append(oid)

        for name, oid in result.oids_to_resolve.items():
            resolver.register(oid, name)

        for index_mapping in result.index_mappings:
            resolver.register_index(tag=index_mapping.tag, index=index_mapping.index, mapping=index_mapping.mapping)

        for batch in result.table_batches.values():
            should_query_in_bulk = bulk_threshold and len(batch.oids) > bulk_threshold
            if should_query_in_bulk:
                bulk_oids.append(batch.table_oid)
            else:
                # NOTE: we should issue GETNEXT commands for these OIDs, because GET commands on table column OIDs
                # never succeed.
                # This is because data for a given entry in the table is available at the column OIDs **suffixed
                # with the table entry index**, i.e. `<COLUMN_OID>.<ENTRY_INDEX>`. (There's nothing at `<COLUMN_OID>`.)
                next_oids.extend(batch.oids)

        parsed_metrics.extend(result.parsed_metrics)

    return {'oids': oids, 'next_oids': next_oids, 'bulk_oids': bulk_oids, 'parsed_metrics': parsed_metrics}
def parse_metrics ( metrics , resolver , logger , bulk_threshold = 0 ) : # type: (List[Metric], OIDResolver, Optional[Logger], int) -> ParseMetricsResult oids = [ ] next_oids = [ ] bulk_oids = [ ] parsed_metrics = [ ] # type: List[ParsedMetric] for metric in metrics : result = _parse_metric ( metric , logger ) for oid in result . oids_to_fetch : oids . append ( oid ) for name , oid in result . oids_to_resolve . items ( ) : resolver . register ( oid , name ) for index_mapping in result . index_mappings : resolver . register_index ( tag = index_mapping . tag , index = index_mapping . index , mapping = index_mapping . mapping ) for batch in result . table_batches . values ( ) : should_query_in_bulk = bulk_threshold and len ( batch . oids ) > bulk_threshold if should_query_in_bulk : bulk_oids . append ( batch . table_oid ) else : # NOTE: we should issue GETNEXT commands for these OIDs, because GET commands on table column OIDs # never succeed. # This is because data for a given entry in the table is available at the column OIDs **suffixed # with the table entry index**, i.e. `<COLUMN_OID>.<ENTRY_INDEX>`. (There's nothing at `<COLUMN_OID>`.) next_oids . extend ( batch . oids ) parsed_metrics . extend ( result . parsed_metrics ) return { 'oids' : oids , 'next_oids' : next_oids , 'bulk_oids' : bulk_oids , 'parsed_metrics' : parsed_metrics }