From 051f801a36d9cc891a8daf05c599aa131d55f1e2 Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Sun, 30 Jun 2019 13:38:13 +0200 Subject: [PATCH] Udate dependencies Signed-off-by: Xabier Larrakoetxea --- go.mod | 10 +- go.sum | 59 ++++++-- .../client_golang/api/prometheus/v1/API.go | 142 ++++++++++++++++-- .../service/metric/prometheus/prometheus.go | 4 +- .../metric/prometheus/prometheus_test.go | 4 +- 5 files changed, 186 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index 0d47666..8f2dabe 100644 --- a/go.mod +++ b/go.mod @@ -4,16 +4,14 @@ require ( github.com/DATA-DOG/go-sqlmock v1.3.3 // indirect github.com/JensRantil/graphite-client v0.0.0-20151206234601-d93bf4b72f5a github.com/alecthomas/kingpin v2.2.6+incompatible - github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect - github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/lucasb-eyer/go-colorful v1.0.1 github.com/mattn/go-runewidth v0.0.4 // indirect - github.com/mum4k/termdash v0.8.1-0.20190509013946-d34e18ab097b - github.com/nsf/termbox-go v0.0.0-20190325093121-288510b9734e // indirect + github.com/mum4k/termdash v0.10.0 + github.com/nsf/termbox-go v0.0.0-20190624072549-eeb6cd0a1762 // indirect github.com/oklog/run v1.0.0 - github.com/prometheus/client_golang v0.9.2 - github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 + github.com/prometheus/client_golang v1.0.0 + github.com/prometheus/common v0.6.0 github.com/rs/zerolog v1.13.0 github.com/stretchr/testify v1.3.0 ) diff --git a/go.sum b/go.sum index 93cda38..51e10cd 100644 --- a/go.sum +++ b/go.sum @@ -9,9 +9,23 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lucasb-eyer/go-colorful v1.0.1 h1:nKJRBvZWPzvkwB4sY8A3U4zgqLf2Y9c02yzPsbXu/5c= @@ -19,26 +33,51 @@ github.com/lucasb-eyer/go-colorful v1.0.1/go.mod h1:tLy1nWSoU0DGtxQyNRrUmb6PUiB7 github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mum4k/termdash v0.8.1-0.20190509013946-d34e18ab097b h1:CY7RxLLUl0IZNYsBfv9FD+HDDBqFyF8JLf2fkHDXZW4= -github.com/mum4k/termdash v0.8.1-0.20190509013946-d34e18ab097b/go.mod h1:l3tO+lJi9LZqXRq7cu7h5/8rDIK3AzelSuq2v/KncxI= -github.com/nsf/termbox-go v0.0.0-20190325093121-288510b9734e h1:Vbib8wJAaMEF9jusI/kMSYMr/LtRzM7+F9MJgt/nH8k= -github.com/nsf/termbox-go v0.0.0-20190325093121-288510b9734e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mum4k/termdash v0.10.0 h1:uqM6ePiMf+smecb1tJJeON36o1hREeCfOmLFG0iz4a0= +github.com/mum4k/termdash v0.10.0/go.mod h1:l3tO+lJi9LZqXRq7cu7h5/8rDIK3AzelSuq2v/KncxI= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nsf/termbox-go v0.0.0-20190624072549-eeb6cd0a1762 h1:44Lv0bNi88GweB54TCjB/lEJgp+2Ze5WFpwNu0nh0ag= +github.com/nsf/termbox-go v0.0.0-20190624072549-eeb6cd0a1762/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= +github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/rs/zerolog v1.13.0 h1:hSNcYHyxDWycfePW7pUI8swuFkcSMPKh3E63Pokg1Hk= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/mocks/github.com/prometheus/client_golang/api/prometheus/v1/API.go b/internal/mocks/github.com/prometheus/client_golang/api/prometheus/v1/API.go index 7ec5a2c..e250962 100644 --- a/internal/mocks/github.com/prometheus/client_golang/api/prometheus/v1/API.go +++ b/internal/mocks/github.com/prometheus/client_golang/api/prometheus/v1/API.go @@ -2,6 +2,7 @@ package v1 +import api "github.com/prometheus/client_golang/api" import context "context" import mock "github.com/stretchr/testify/mock" import model "github.com/prometheus/common/model" @@ -35,6 +36,27 @@ func (_m *API) AlertManagers(ctx context.Context) (v1.AlertManagersResult, error return r0, r1 } +// Alerts provides a mock function with given fields: ctx +func (_m *API) Alerts(ctx context.Context) (v1.AlertsResult, error) { + ret := _m.Called(ctx) + + var r0 v1.AlertsResult + if rf, ok := ret.Get(0).(func(context.Context) v1.AlertsResult); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(v1.AlertsResult) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // CleanTombstones provides a mock function with given fields: ctx func (_m *API) CleanTombstones(ctx context.Context) error { ret := _m.Called(ctx) @@ -107,6 +129,29 @@ func (_m *API) Flags(ctx context.Context) (v1.FlagsResult, error) { return r0, r1 } +// LabelNames provides a mock function with given fields: ctx +func (_m *API) LabelNames(ctx context.Context) ([]string, error) { + ret := _m.Called(ctx) + + var r0 []string + if rf, ok := ret.Get(0).(func(context.Context) []string); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // LabelValues provides a mock function with given fields: ctx, label func (_m *API) LabelValues(ctx context.Context, label string) (model.LabelValues, error) { ret := _m.Called(ctx, label) @@ -131,7 +176,7 @@ func (_m *API) LabelValues(ctx context.Context, label string) (model.LabelValues } // Query provides a mock function with given fields: ctx, query, ts -func (_m *API) Query(ctx context.Context, query string, ts time.Time) (model.Value, error) { +func (_m *API) Query(ctx context.Context, query string, ts time.Time) (model.Value, api.Warnings, error) { ret := _m.Called(ctx, query, ts) var r0 model.Value @@ -143,18 +188,27 @@ func (_m *API) Query(ctx context.Context, query string, ts time.Time) (model.Val } } - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, time.Time) error); ok { + var r1 api.Warnings + if rf, ok := ret.Get(1).(func(context.Context, string, time.Time) api.Warnings); ok { r1 = rf(ctx, query, ts) } else { - r1 = ret.Error(1) + if ret.Get(1) != nil { + r1 = ret.Get(1).(api.Warnings) + } } - return r0, r1 + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string, time.Time) error); ok { + r2 = rf(ctx, query, ts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 } // QueryRange provides a mock function with given fields: ctx, query, r -func (_m *API) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error) { +func (_m *API) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, api.Warnings, error) { ret := _m.Called(ctx, query, r) var r0 model.Value @@ -166,9 +220,39 @@ func (_m *API) QueryRange(ctx context.Context, query string, r v1.Range) (model. } } - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, v1.Range) error); ok { + var r1 api.Warnings + if rf, ok := ret.Get(1).(func(context.Context, string, v1.Range) api.Warnings); ok { r1 = rf(ctx, query, r) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(api.Warnings) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string, v1.Range) error); ok { + r2 = rf(ctx, query, r) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// Rules provides a mock function with given fields: ctx +func (_m *API) Rules(ctx context.Context) (v1.RulesResult, error) { + ret := _m.Called(ctx) + + var r0 v1.RulesResult + if rf, ok := ret.Get(0).(func(context.Context) v1.RulesResult); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(v1.RulesResult) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) } else { r1 = ret.Error(1) } @@ -177,7 +261,7 @@ func (_m *API) QueryRange(ctx context.Context, query string, r v1.Range) (model. } // Series provides a mock function with given fields: ctx, matches, startTime, endTime -func (_m *API) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error) { +func (_m *API) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, api.Warnings, error) { ret := _m.Called(ctx, matches, startTime, endTime) var r0 []model.LabelSet @@ -189,14 +273,23 @@ func (_m *API) Series(ctx context.Context, matches []string, startTime time.Time } } - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, []string, time.Time, time.Time) error); ok { + var r1 api.Warnings + if rf, ok := ret.Get(1).(func(context.Context, []string, time.Time, time.Time) api.Warnings); ok { r1 = rf(ctx, matches, startTime, endTime) } else { - r1 = ret.Error(1) + if ret.Get(1) != nil { + r1 = ret.Get(1).(api.Warnings) + } } - return r0, r1 + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, []string, time.Time, time.Time) error); ok { + r2 = rf(ctx, matches, startTime, endTime) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 } // Snapshot provides a mock function with given fields: ctx, skipHead @@ -240,3 +333,26 @@ func (_m *API) Targets(ctx context.Context) (v1.TargetsResult, error) { return r0, r1 } + +// TargetsMetadata provides a mock function with given fields: ctx, matchTarget, metric, limit +func (_m *API) TargetsMetadata(ctx context.Context, matchTarget string, metric string, limit string) ([]v1.MetricMetadata, error) { + ret := _m.Called(ctx, matchTarget, metric, limit) + + var r0 []v1.MetricMetadata + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) []v1.MetricMetadata); ok { + r0 = rf(ctx, matchTarget, metric, limit) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]v1.MetricMetadata) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, matchTarget, metric, limit) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/internal/service/metric/prometheus/prometheus.go b/internal/service/metric/prometheus/prometheus.go index cdaf03d..019ae21 100644 --- a/internal/service/metric/prometheus/prometheus.go +++ b/internal/service/metric/prometheus/prometheus.go @@ -37,7 +37,7 @@ func NewGatherer(cfg ConfigGatherer) metric.Gatherer { func (g *gatherer) GatherSingle(ctx context.Context, query model.Query, t time.Time) ([]model.MetricSeries, error) { // Get value from Prometheus. - val, err := g.cli.Query(ctx, query.Expr, t) + val, _, err := g.cli.Query(ctx, query.Expr, t) if err != nil { return []model.MetricSeries{}, err } @@ -53,7 +53,7 @@ func (g *gatherer) GatherSingle(ctx context.Context, query model.Query, t time.T func (g *gatherer) GatherRange(ctx context.Context, query model.Query, start, end time.Time, step time.Duration) ([]model.MetricSeries, error) { // Get value from Prometheus. - val, err := g.cli.QueryRange(ctx, query.Expr, promv1.Range{ + val, _, err := g.cli.QueryRange(ctx, query.Expr, promv1.Range{ Start: start, End: end, Step: step, diff --git a/internal/service/metric/prometheus/prometheus_test.go b/internal/service/metric/prometheus/prometheus_test.go index 4fca89d..72ec93f 100644 --- a/internal/service/metric/prometheus/prometheus_test.go +++ b/internal/service/metric/prometheus/prometheus_test.go @@ -85,7 +85,7 @@ func TestGathererGatherSingle(t *testing.T) { // Mocks. mapi := &mpromv1.API{} - mapi.On("Query", mock.Anything, mock.Anything, mock.Anything).Once().Return(test.prommetric, expErr) + mapi.On("Query", mock.Anything, mock.Anything, mock.Anything).Once().Return(test.prommetric, nil, expErr) test.cfg.Client = mapi g := prometheus.NewGatherer(test.cfg) @@ -235,7 +235,7 @@ func TestGathererGatherRange(t *testing.T) { // Mocks. mapi := &mpromv1.API{} - mapi.On("QueryRange", mock.Anything, mock.Anything, mock.Anything).Once().Return(test.prommetric, expErr) + mapi.On("QueryRange", mock.Anything, mock.Anything, mock.Anything).Once().Return(test.prommetric, nil, expErr) test.cfg.Client = mapi g := prometheus.NewGatherer(test.cfg)