@@ -15,6 +15,7 @@ import (
15
15
"github.com/grafana/grafana-plugin-sdk-go/backend"
16
16
sdkHTTPClient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
17
17
"github.com/grafana/grafana-plugin-sdk-go/data"
18
+ "github.com/grafana/grafana/pkg/tsdb/prometheus/client"
18
19
apiv1 "github.com/prometheus/client_golang/api/prometheus/v1"
19
20
"github.com/prometheus/common/model"
20
21
"go.opentelemetry.io/otel/attribute"
@@ -68,7 +69,7 @@ type Buffered struct {
68
69
// New creates and object capable of executing and parsing a Prometheus queries. It's "buffered" because there is
69
70
// another implementation capable of streaming parse the response.
70
71
func New (roundTripper http.RoundTripper , tracer tracing.Tracer , settings backend.DataSourceInstanceSettings , plog log.Logger ) (* Buffered , error ) {
71
- promClient , err := CreateClient (roundTripper , settings .URL )
72
+ promClient , err := client . CreateAPIClient (roundTripper , settings .URL )
72
73
if err != nil {
73
74
return nil , fmt .Errorf ("error creating prom client: %v" , err )
74
75
}
@@ -232,7 +233,7 @@ func (b *Buffered) parseTimeSeriesQuery(req *backend.QueryDataRequest) ([]*Prome
232
233
if err != nil {
233
234
return nil , fmt .Errorf ("error unmarshaling query model: %v" , err )
234
235
}
235
- //Final interval value
236
+ // Final interval value
236
237
interval , err := calculatePrometheusInterval (model , b .TimeInterval , query , b .intervalCalculator )
237
238
if err != nil {
238
239
return nil , fmt .Errorf ("error calculating interval: %v" , err )
@@ -301,7 +302,7 @@ func parseTimeSeriesResponse(value map[TimeSeriesQueryType]interface{}, query *P
301
302
func calculatePrometheusInterval (model * QueryModel , timeInterval string , query backend.DataQuery , intervalCalculator intervalv2.Calculator ) (time.Duration , error ) {
302
303
queryInterval := model .Interval
303
304
304
- //If we are using variable for interval/step, we will replace it with calculated interval
305
+ // If we are using variable for interval/step, we will replace it with calculated interval
305
306
if isVariableInterval (queryInterval ) {
306
307
queryInterval = ""
307
308
}
@@ -656,7 +657,7 @@ func isVariableInterval(interval string) bool {
656
657
if interval == varInterval || interval == varIntervalMs || interval == varRateInterval {
657
658
return true
658
659
}
659
- //Repetitive code, we should have functionality to unify these
660
+ // Repetitive code, we should have functionality to unify these
660
661
if interval == varIntervalAlt || interval == varIntervalMsAlt || interval == varRateIntervalAlt {
661
662
return true
662
663
}
0 commit comments