Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
only export float64 metrics of heap_info
Browse files Browse the repository at this point in the history
  • Loading branch information
vlorinc authored and guvenc committed Apr 30, 2024
1 parent 0bd1fff commit d22c9d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
r := prometheus.NewRegistry()
r.MustRegister(metrics.InterfaceStat)
r.MustRegister(metrics.CallCount)
r.MustRegister(metrics.HeapInfo)

http.Handle("/metrics", promhttp.HandlerFor(r, promhttp.HandlerOpts{}))

Expand Down
8 changes: 7 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ func queryTelemetry(conn net.Conn, log *logrus.Logger, command string, response

func Update(conn net.Conn, hostname string, log *logrus.Logger) {
var dpserviceHeapInfo DpServiceHeapInfo
queryTelemetry(conn, log, "/eal/heap_info", &dpserviceHeapInfo)
queryTelemetry(conn, log, "/eal/heap_info,0", &dpserviceHeapInfo)
for key, value := range dpserviceHeapInfo.Value {
// Only export metrics of type float64 (/eal/heap_info contains also some string values)
if v, ok := value.(float64); ok {
HeapInfo.With(prometheus.Labels{"node_name": hostname, "info": key}).Set(v)
}
}

var ethdevList EthdevList
queryTelemetry(conn, log, "/ethdev/list", &ethdevList)
Expand Down
2 changes: 1 addition & 1 deletion metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ type DpServiceGraphCallCount struct {
}

type DpServiceHeapInfo struct {
Value map[string]int `json:"/eal/heap_info"`
Value map[string]any `json:"/eal/heap_info"`
}

0 comments on commit d22c9d3

Please sign in to comment.