8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exemplars are specified as being for Histogram and Counter types, and supported by this client for Histogram and Counter types.
However for custom collectors HistogramMetricFamily supports exemplars, but CounterMetricFamily does not.
Support should be added to CounterMetricFamily.
This shouldn't be too hard, it was added to the underlying layers for HistogramMetricFamily support.
The text was updated successfully, but these errors were encountered:
Workaround until the MR is released.
from typing import Optional, Union, Sequence, Timestamp from prometheus_client.core import CounterMetricFamily, Exemplar, Sample class MyCounterMetricFamily(CounterMetricFamily): """ Standard class doesn't support exemplars, so we hack it in. See https://github.com/prometheus/client_python/issues/1062 """ def __init__( self, name: str, documentation: str, value: Optional[float] = None, labels: Optional[Sequence[str]] = None, created: Optional[float] = None, unit: str = "", exemplar: Optional[Exemplar] = None, ): # Run normal, but don't pass in value CounterMetricFamily.__init__(self, name, documentation, None, labels, created, unit) if value is not None: self.add_metric([], value, created, exemplar=exemplar) def add_metric( self, labels: Sequence[str], value: float, created: Optional[float] = None, timestamp: Optional[Union[Timestamp, float]] = None, exemplar: Optional[Exemplar] = None, ) -> None: self.samples.append( Sample(self.name + "_total", dict(zip(self._labelnames, labels)), value, timestamp, exemplar) ) if created is not None: self.samples.append(Sample(self.name + "_created", dict(zip(self._labelnames, labels)), created, timestamp))
Sorry, something went wrong.
37cd873
Successfully merging a pull request may close this issue.
Exemplars are specified as being for Histogram and Counter types, and supported by this client for Histogram and Counter types.
However for custom collectors HistogramMetricFamily supports exemplars, but CounterMetricFamily does not.
Support should be added to CounterMetricFamily.
This shouldn't be too hard, it was added to the underlying layers for HistogramMetricFamily support.
The text was updated successfully, but these errors were encountered: