We often need to aggregate together multiple infos. Most keys can
    just be clobbered by the new info, but e.g. any keys which contain
    counts should be added. The merge schema is indicated by the key
    namespace.

    Namespaces:

    - stats.timers: Timing
    - stats.gauges: Gauge values
    - stats.*: Counts of a quantity

def merge_infos(info1, info2):
    """We often need to aggregate together multiple infos. Most keys can
    just be clobbered by the new info, but e.g. any keys which contain
    counts should be added. The merge schema is indicated by the key
    namespace.

    Namespaces:

    - stats.timers: Timing
    - stats.gauges: Gauge values
    - stats.*: Counts of a quantity
    """
    for key, value in six.iteritems(info2):
        if key in info1 and key.startswith('stats'):
            if key.startswith('stats.timers'):
                # timer
                info1[key] += value
            elif key.startswith('stats.gauges'):
                # gauge
                info1[key] = value
            else:
                # counter
                info1[key] += value
        else:
            info1[key] = value