.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.openmetrics.OpenMetricsFamily Class Reference

Public Member Functions

 __init__ (self, str key, OMFTypeHintType type_hint, str help_hint, OMFDataInfoType data_info, list[t.Any] data)
 __str__ (self)

Public Attributes

str key = key
OMFTypeHintType type_hint = type_hint
str help_hint = help_hint
OMFDataInfoType data_info = data_info
OMFDataType data = data

Detailed Description

A family of metrics.

- The ``key`` parameter is the metric name that should be used (snake case).
- The ``type_hint`` parameter must be one of ``counter``, ``gauge``,
  ``histogram``, ``summary``.
- The ``help_hint`` parameter is a short string explaining the metric.
- The data_info parameter is a dictionary of descriptionary parameters for
  the data point (e.g. request method/path).

- The data parameter is a flat list of the actual data in shape of a
  primitive type.

See `OpenMetrics specification`_ for more information.

.. _OpenMetrics specification:
   https://github.com/prometheus/OpenMetrics/blob/main/specification/OpenMetrics.txt

Definition at line 11 of file openmetrics.py.

Constructor & Destructor Documentation

◆ __init__()

searx.openmetrics.OpenMetricsFamily.__init__ ( self,
str key,
OMFTypeHintType type_hint,
str help_hint,
OMFDataInfoType data_info,
list[t.Any] data )

Definition at line 31 of file openmetrics.py.

33 ):
34 self.key: str = key
35 self.type_hint: OMFTypeHintType = type_hint
36 self.help_hint: str = help_hint
37 self.data_info: OMFDataInfoType = data_info
38 self.data: OMFDataType = data
39

Member Function Documentation

◆ __str__()

searx.openmetrics.OpenMetricsFamily.__str__ ( self)

Definition at line 40 of file openmetrics.py.

40 def __str__(self):
41 text_representation = f"""\
42# HELP {self.key} {self.help_hint}
43# TYPE {self.key} {self.type_hint}
44"""
45
46 for i, data_info_dict in enumerate(self.data_info):
47 if not data_info_dict or not self.data[i]:
48 continue
49
50 info_representation = ','.join([f'{key}="{value}"' for (key, value) in data_info_dict.items()])
51 text_representation += f'{self.key}{{{info_representation}}} {self.data[i]}\n'
52
53 return text_representation

References data, and data_info.

Member Data Documentation

◆ data

OMFDataType searx.openmetrics.OpenMetricsFamily.data = data

Definition at line 38 of file openmetrics.py.

Referenced by __str__().

◆ data_info

searx.openmetrics.OpenMetricsFamily.data_info = data_info

Definition at line 37 of file openmetrics.py.

Referenced by __str__().

◆ help_hint

str searx.openmetrics.OpenMetricsFamily.help_hint = help_hint

Definition at line 36 of file openmetrics.py.

◆ key

str searx.openmetrics.OpenMetricsFamily.key = key

◆ type_hint

OMFTypeHintType searx.openmetrics.OpenMetricsFamily.type_hint = type_hint

Definition at line 35 of file openmetrics.py.


The documentation for this class was generated from the following file: