(expected_element, submitted_elements)
return sorted(similar_elements, reverse=True)
Return similar elements (metrics, service checks) received compared to the submitted elements
Return similar elements (metrics, service checks) received compared to the submitted elements
Return similar elements ( metrics service checks ) received compared to the submitted elements
def _build_similar_elements(expected_element, submitted_elements):
    """
    Return similar elements (metrics, service checks) received compared to the submitted elements
    """
    if isinstance(expected_element, MetricStub):
        scoring_fn = _get_similarity_score_for_metric
    elif isinstance(expected_element, ServiceCheckStub):
        scoring_fn = _get_similarity_score_for_service_check
    elif isinstance(expected_element, HistogramBucketStub):
        scoring_fn = _get_similarity_score_for_histogram_bucket
    else:
        raise NotImplementedError("Invalid type: {}".format(expected_element))

    similar_elements = []
    for _, metric_stubs in iteritems(submitted_elements):
        for candidate_metric in metric_stubs:
            score = scoring_fn(expected_element, candidate_metric)
            similar_elements.append((score, candidate_metric))
    return sorted(similar_elements, reverse=True)
def _build_similar_elements ( expected_element , submitted_elements ) : if isinstance ( expected_element , MetricStub ) : scoring_fn = _get_similarity_score_for_metric elif isinstance ( expected_element , ServiceCheckStub ) : scoring_fn = _get_similarity_score_for_service_check elif isinstance ( expected_element , HistogramBucketStub ) : scoring_fn = _get_similarity_score_for_histogram_bucket else : raise NotImplementedError ( "Invalid type: {}" . format ( expected_element ) ) similar_elements = [ ] for _ , metric_stubs in iteritems ( submitted_elements ) : for candidate_metric in metric_stubs : score = scoring_fn ( expected_element , candidate_metric ) similar_elements . append ( ( score , candidate_metric ) ) return sorted ( similar_elements , reverse = True )