Modify the metric "Info" to "Gauge"

This commit fixes the bug encountered while feeding data to
scraping tools.
- Openmetric keyword "Info" is not compatible with general
scraping tools. Alternative is to use "Gauge" for displaying
device information.

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

Story: 2010918
Task: 50117

Change-Id: I57ed6ac379aeee56ea4469fd561777d335ede32e
Signed-off-by: Aman Pandae <AmanPandae.Mothukuri@windriver.com>
This commit is contained in:
Aman Pandae 2024-05-19 05:12:31 -04:00 committed by Aman Pandae
parent 3997879fa0
commit b8d44bc001

View File

@ -122,7 +122,7 @@ func convertToOpnMetFormat(pfd PfDevices, p VfpodInfo) string {
// Function to cast PfDevice data from struct to openmetrics format
func devStatOpenMet(devInfo PfDevice) string {
var reg = openmetrics.NewRegistry()
regName := "network_interface_device"
regName := "network_interface_device_info"
// OpenMetrics Not showing Fields if it is empty
// so adding a Blank string to show alias
@ -144,7 +144,7 @@ func devStatOpenMet(devInfo PfDevice) string {
alias,
devInfo.OperState,
devInfo.Pciaddr,
)
).Add(float64(1))
// convert all netlink.LinkStatistics Struct to map
fields := reflect.TypeOf(*devInfo.Statistics)
@ -182,9 +182,9 @@ func devStatOpenMet(devInfo PfDevice) string {
// for Network Interface Device Info
func regDevInfo(
reg *openmetrics.Registry, name string, help string, labels []string,
) openmetrics.InfoFamily {
) openmetrics.GaugeFamily {
var deviceInfo = reg.Info(openmetrics.Desc{
var deviceInfo = reg.Gauge(openmetrics.Desc{
Name: name,
Help: help,
Labels: labels,