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

Public Member Functions

 __init__ (self, str key, str type_hint, str help_hint, list data_info, list data)
 
 __str__ (self)
 

Public Attributes

 key = key
 
 type_hint = type_hint
 
 help_hint = help_hint
 
 data_info = data_info
 
 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 primive type.

See https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md for more information.

Definition at line 5 of file openmetrics.py.

Constructor & Destructor Documentation

◆ __init__()

searx.openmetrics.OpenMetricsFamily.__init__ ( self,
str key,
str type_hint,
str help_hint,
list data_info,
list data )

Definition at line 16 of file openmetrics.py.

16 def __init__(self, key: str, type_hint: str, help_hint: str, data_info: list, data: list):
17 self.key = key
18 self.type_hint = type_hint
19 self.help_hint = help_hint
20 self.data_info = data_info
21 self.data = data
22

Member Function Documentation

◆ __str__()

searx.openmetrics.OpenMetricsFamily.__str__ ( self)

Definition at line 23 of file openmetrics.py.

23 def __str__(self):
24 text_representation = f"""# HELP {self.key} {self.help_hint}
25# TYPE {self.key} {self.type_hint}
26"""
27
28 for i, data_info_dict in enumerate(self.data_info):
29 if not data_info_dict or not self.data[i]:
30 continue
31
32 info_representation = ','.join([f"{key}=\"{value}\"" for (key, value) in data_info_dict.items()])
33 text_representation += f"{self.key}{{{info_representation}}} {self.data[i]}\n"
34
35 return text_representation

References searx.openmetrics.OpenMetricsFamily.data, and searx.openmetrics.OpenMetricsFamily.data_info.

Member Data Documentation

◆ data

searx.openmetrics.OpenMetricsFamily.data = data

Definition at line 21 of file openmetrics.py.

Referenced by searx.openmetrics.OpenMetricsFamily.__str__().

◆ data_info

searx.openmetrics.OpenMetricsFamily.data_info = data_info

Definition at line 20 of file openmetrics.py.

Referenced by searx.openmetrics.OpenMetricsFamily.__str__().

◆ help_hint

searx.openmetrics.OpenMetricsFamily.help_hint = help_hint

Definition at line 19 of file openmetrics.py.

◆ key

searx.openmetrics.OpenMetricsFamily.key = key

◆ type_hint

searx.openmetrics.OpenMetricsFamily.type_hint = type_hint

Definition at line 18 of file openmetrics.py.


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