| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6e22fb5 commit fb072c2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,9 @@ | |||
| 25 | 25 | def _is_valid_exemplar_metric(metric, sample): | |
| 26 | 26 | if metric.type == 'counter' and sample.name.endswith('_total'): | |
| 27 | 27 | return True | |
| 28 | - if metric.type in ('gaugehistogram') and sample.name.endswith('_bucket'): | ||
| 28 | + if metric.type == 'gaugehistogram' and sample.name.endswith('_bucket'): | ||
| 29 | 29 | return True | |
| 30 | - if metric.type in ('histogram') and sample.name.endswith('_bucket') or sample.name == metric.name: | ||
| 30 | + if metric.type == 'histogram' and (sample.name.endswith('_bucket') or sample.name == metric.name): | ||
| 31 | 31 | return True | |
| 32 | 32 | return False | |
| 33 | 33 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -347,6 +347,21 @@ def collect(self): | |||
| 347 | 347 | with self.assertRaises(ValueError): | |
| 348 | 348 | generate_latest(self.registry) | |
| 349 | 349 | ||
| 350 | + def test_gauge_exemplar(self) -> None: | ||
| 351 | + class MyCollector: | ||
| 352 | + def collect(self): | ||
| 353 | + metric = Metric("gg", "A gauge", 'gauge') | ||
| 354 | + # A sample whose name equals the metric name must not be | ||
| 355 | + # treated as exemplar-eligible just because it matches; | ||
| 356 | + # only histogram/gaugehistogram buckets, counter _total, and | ||
| 357 | + # native histograms may carry exemplars. | ||
| 358 | + metric.add_sample("gg", {}, 1, None, Exemplar({'a': 'b'}, 0.5)) | ||
| 359 | + yield metric | ||
| 360 | + | ||
| 361 | + self.registry.register(MyCollector()) | ||
| 362 | + with self.assertRaises(ValueError): | ||
| 363 | + generate_latest(self.registry) | ||
| 364 | + | ||
| 350 | 365 | def test_gaugehistogram(self) -> None: | |
| 351 | 366 | self.custom_collector( | |
| 352 | 367 | GaugeHistogramMetricFamily('gh', 'help', buckets=[('1.0', 4), ('+Inf', (5))], gsum_value=7)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments