Skip to content

How to use Custom Collectors for Histograms #683

@cunningr

Description

@cunningr

When using a histogram metrics we can use the 'observe' method to evaluate which bucket our latest sample will fall in:

E.g.
h1.labels('device-1').observe(value.get('latest_sample'))
->

        for i, bound in enumerate(self._upper_bounds):
            if amount <= bound:
                self._buckets[i].inc(1)
                break

However as I am proxying metrics I believe I should be using a Customer Collector and the HistogramMetricFamily which only provides add_metric which seems to just populate all the buckets.

am I supposed to calculate the buckets in my code before writing the metric?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions