Skip to content

Commit

Permalink
debug metrics collection
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrox committed Sep 28, 2024
1 parent bd82068 commit 2f96321
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions e2e/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,15 @@ func getNodeMetrics(c client.Client, cfg *rest.Config) (map[string]*dto.MetricFa
if err != nil {
return nil, err
}
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

var parser expfmt.TextParser
mfs, err := parser.TextToMetricFamilies(resp.Body)
mfs, err := parser.TextToMetricFamilies(bytes.NewReader(b))
if err != nil {
return nil, err
return nil, fmt.Errorf("reading metrics body: %s", b)
}

return mfs, nil
Expand Down
2 changes: 2 additions & 0 deletions manager/metrics_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package manager

import (
"context"
"fmt"
"io"
"log/slog"
"net"
Expand Down Expand Up @@ -39,6 +40,7 @@ func fetchMetricsAndMerge(w io.Writer) {
shimMetrics, err := getMetricsOverTTRPC(context.Background(), sockName)
if err != nil {
slog.Error("getting metrics", "err", err)
fmt.Fprintf(w, "getting metrics error: %s", err)
// we still want to read the rest of the sockets
continue
}
Expand Down

0 comments on commit 2f96321

Please sign in to comment.