'Function to create a histogram metric for "rate" like metrics.
Warning this doesn\'t use the harmonic mean, beware of what it means when using it.
:param metric: The name of the metric
:param value: The value to sample for the histogram
:param excluding_tags: A list of tags that will be removed when computing the histogram
:param tags: (optional) A list of tags for this metric
:param hostname: (optional) A hostname for this metric. Defaults to the current hostname.
:param device_name: (optional) The device name for this metric'

def historate(self, metric, value, excluding_tags, tags=None, hostname=None, device_name=None):

    tags = list(tags)
    context = [metric]
    if (tags is not None):
        context.append('-'.join(sorted(tags)))
    if (hostname is not None):
        context.append(('host:' + hostname))
    if (device_name is not None):
        context.append(('device:' + device_name))
    now = time.time()
    context = tuple(context)
    if (context in self.historate_dict):
        if (tags is not None):
            for tag in list(tags):
                for exc_tag in excluding_tags:
                    if tag.startswith('{0}:'.format(exc_tag)):
                        tags.remove(tag)
        (prev_value, prev_ts) = self.historate_dict[context]
        rate = (float((value - prev_value)) / float((now - prev_ts)))
        self.aggregator.histogram(metric, rate, tags, hostname, device_name)
    self.historate_dict[context] = (value, now)
