def merge(metric_kind, prior, latest):
    """Merges `prior` and `latest`

    Args:
       metric_kind (:class:`MetricKind`): indicates the kind of metrics
         being merged
       prior (:class:`MetricValue`): an prior instance of the metric
       latest (:class:`MetricValue`: the latest instance of the metric
    """
    prior_type, _ = _detect_value(prior)
    latest_type, _ = _detect_value(latest)
    if prior_type != latest_type:
        _logger.warn(u'Metric values are not compatible: %s, %s',
                     prior, latest)
        raise ValueError(u'Incompatible delta metric values')
    if prior_type is None:
        _logger.warn(u'Bad metric values, types not known for : %s, %s',
                     prior, latest)
        raise ValueError(u'Unsupported delta metric types')

    if metric_kind == MetricKind.DELTA:
        return _merge_delta_metric(prior, latest)
    else:
        return _merge_cumulative_or_gauge_metrics(prior, latest)
def merge ( metric_kind , prior , latest ) : prior_type , _ = _detect_value ( prior ) latest_type , _ = _detect_value ( latest ) if prior_type != latest_type : _logger . warn ( u'Metric values are not compatible: %s, %s' , prior , latest ) raise ValueError ( u'Incompatible delta metric values' ) if prior_type is None : _logger . warn ( u'Bad metric values, types not known for : %s, %s' , prior , latest ) raise ValueError ( u'Unsupported delta metric types' ) if metric_kind == MetricKind . DELTA : return _merge_delta_metric ( prior , latest ) else : return _merge_cumulative_or_gauge_metrics ( prior , latest )
Merges `prior` and `latest`

    Args:
       metric_kind (:class:`MetricKind`): indicates the kind of metrics
         being merged
       prior (:class:`MetricValue`): an prior instance of the metric
       latest (:class:`MetricValue`: the latest instance of the metric