MCPcopy Index your code
hub / github.com/prometheus/client_python / build_metric

Function build_metric

prometheus_client/parser.py:290–303  ·  view source on GitHub ↗
(name: str, documentation: str, typ: str, samples: List[Sample])

Source from the content-addressed store, hash-verified

288 allowed_names = []
289
290 def build_metric(name: str, documentation: str, typ: str, samples: List[Sample]) -> Metric:
291 # Munge counters into OpenMetrics representation
292 # used internally.
293 if typ == 'counter':
294 if name.endswith('_total'):
295 name = name[:-6]
296 else:
297 new_samples = []
298 for s in samples:
299 new_samples.append(Sample(s[0] + '_total', *s[1:]))
300 samples = new_samples
301 metric = Metric(name, documentation, typ)
302 metric.samples = samples
303 return metric
304
305 for line in fd:
306 line = line.strip()

Callers 1

Calls 2

SampleClass · 0.85
MetricClass · 0.85

Tested by

no test coverage detected