@cryptotaxi247 / netdata-1 / commits / 35cd0ee1c

fix(go.d/prometheus): correct unsupported protocol scheme "file" error (#18938)

Ilya Mashchenko committed Nov 4, 2024 at 22:02 UTC 35cd0ee1cda31037691898e6713f19b9c491814f
2 files changed +10 -5
src/go/plugin/go.d/pkg/prometheus/client.go
+1 -5
@@ -47,11 +47,7 @@ const (
47
48 // New creates a Prometheus instance.
49 func New(client *http.Client, request web.RequestConfig) Prometheus {
50 - return &prometheus{
51 - client: client,
52 - request: request,
53 - buf: bytes.NewBuffer(make([]byte, 0, 16000)),
54 - }
50 + return NewWithSelector(client, request, nil)
51 }
52
53 // NewWithSelector creates a Prometheus instance with the selector.
src/go/plugin/go.d/pkg/prometheus/client_test.go
+9
@@ -113,6 +113,7 @@ func TestPrometheusGzip(t *testing.T) {
113
114 func TestPrometheusReadFromFile(t *testing.T) {
115 req := web.RequestConfig{URL: "file://testdata/testdata.txt"}
116 +
117 prom := NewWithSelector(http.DefaultClient, req, nil)
118
119 for i := 0; i < 2; i++ {
@@ -120,6 +121,14 @@ func TestPrometheusReadFromFile(t *testing.T) {
121 assert.NoError(t, err)
122 verifyTestData(t, res)
123 }
124 +
125 + prom = New(http.DefaultClient, req)
126 +
127 + for i := 0; i < 2; i++ {
128 + res, err := prom.ScrapeSeries()
129 + assert.NoError(t, err)
130 + verifyTestData(t, res)
131 + }
132 }
133
134 func verifyTestData(t *testing.T, ms Series) {