BugFix: Missing VF info and Pod info

Metric Info was changed to Gauge for Device Info Openmetrics,
Since "Info" keyword is not compatible with scraping tools.
Modifying the same for VF Statistics and VF Pod info.

Minor changes to registry name as "_info" is not suffixed by
Openmetrics registry for gauge

Test Plan:
PASSED: Metrics consumed properly by a scraping tool without
        any error.
PASSED: Validate necessary information is being displayed with
        new metric type Gauge.
PASSED: API Test with SRIOV enabled, VF Pods created and
        verified if the information is retrieved properly

Story: 2010918
Task: 50434

Change-Id: Ia8324b5f1cc390e7ca28443e045d579393527d3a
Signed-off-by: Aman Pandae <AmanPandae.Mothukuri@windriver.com>
This commit is contained in:
Aman Pandae 2024-06-23 08:30:44 -04:00
parent d78c050a20
commit 5d1202f6bc

View File

@ -196,7 +196,7 @@ func regDevInfo(
// Function to cast Pod Details data from struct to openmetrics format
func podStatsOpenMetfmt(podDet map[string]string) string {
var reg = openmetrics.NewRegistry()
regName := "network_interface_vf_kube_pod"
regName := "network_interface_vf_kube_pod_info"
var openMetVar = regDevInfo(
reg, regName, regName, []string{
"namespace", "pod", "container", "resource", "device", "vf",
@ -213,7 +213,7 @@ func podStatsOpenMetfmt(podDet map[string]string) string {
podDet["Vf"],
podDet["Pciaddr"],
podDet["HardwareAddr"],
)
).Add(float64(1))
// create buffer to return
var buf bytes.Buffer
@ -227,7 +227,7 @@ func podStatsOpenMetfmt(podDet map[string]string) string {
// Function to cast VfDevice data from struct to openmetrics format
func vfDeviceOpenMetfmt(devInfo VfDevice) string {
var reg = openmetrics.NewRegistry()
regName := "network_interface_vf_device"
regName := "network_interface_vf_device_info"
var openMetVar = regDevInfo(
reg,
regName,
@ -243,7 +243,7 @@ func vfDeviceOpenMetfmt(devInfo VfDevice) string {
strconv.Itoa(devInfo.VfInfo.Vlan),
BoolToOnOff(devInfo.VfInfo.Spoofchk),
intToOnOff(devInfo.VfInfo.Trust),
)
).Add(float64(1))
statsString := vfStatsOpenMetfmt(devInfo)
// create buffer to return
var buf bytes.Buffer