def METHOD_NAME(self, name, samples, unit):
    # Prometheus histograms are structured as a series of counts
    # with an "le" label. The count of each label signifies all
    # observations with a lower-or-equal value with respect to
    # the "le" label value.
    # After the le-samples, 3 more samples follow, with an overall
    # count, overall sum, and creation timestamp.
    sample_pos = 0
    prev_val = 0
    counts = []
    values = []
    name = self._registry.client.config.prometheus_metrics_prefix + name
    while sample_pos < len(samples):
        sample = samples[sample_pos]
        if "le" in sample.labels:
            values.append(float(sample.labels["le"]))
            counts.append(int(sample.value - prev_val))
            prev_val = sample.value
            sample_pos += 1
        else:
            # we reached the end of one set of buckets/values, this is the "count" sample
            self.histogram(name, unit=unit, buckets=values, **sample.labels).val = counts
            prev_val = 0
            counts = []
            values = []
            sample_pos += 3  # skip sum/created samples