mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Pyroscope: Remove unnecessary import and logic (#79568)
* Remove unecessary import and logic * Update test
This commit is contained in:
parent
ade91e5038
commit
00bc13e37c
@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/plugins"
|
"github.com/grafana/grafana/pkg/plugins"
|
||||||
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
|
||||||
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
"github.com/grafana/grafana/pkg/plugins/manager/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
|
||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
||||||
"github.com/grafana/grafana/pkg/services/searchV2"
|
"github.com/grafana/grafana/pkg/services/searchV2"
|
||||||
@ -97,7 +96,7 @@ func TestIntegrationPluginManager(t *testing.T) {
|
|||||||
ms := mssql.ProvideService(cfg)
|
ms := mssql.ProvideService(cfg)
|
||||||
sv2 := searchV2.ProvideService(cfg, db.InitTestDB(t), nil, nil, tracer, features, nil, nil, nil)
|
sv2 := searchV2.ProvideService(cfg, db.InitTestDB(t), nil, nil, tracer, features, nil, nil, nil)
|
||||||
graf := grafanads.ProvideService(sv2, nil)
|
graf := grafanads.ProvideService(sv2, nil)
|
||||||
pyroscope := pyroscope.ProvideService(hcp, acimpl.ProvideAccessControl(cfg))
|
pyroscope := pyroscope.ProvideService(hcp)
|
||||||
parca := parca.ProvideService(hcp)
|
parca := parca.ProvideService(hcp)
|
||||||
coreRegistry := coreplugin.ProvideCoreRegistry(tracing.InitializeTracerForTest(), am, cw, cm, es, grap, idb, lk, otsdb, pr, tmpo, td, pg, my, ms, graf, pyroscope, parca)
|
coreRegistry := coreplugin.ProvideCoreRegistry(tracing.InitializeTracerForTest(), am, cw, cm, es, grap, idb, lk, otsdb, pr, tmpo, td, pg, my, ms, graf, pyroscope, parca)
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/grafana/grafana-plugin-sdk-go/backend/tracing"
|
"github.com/grafana/grafana-plugin-sdk-go/backend/tracing"
|
||||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
||||||
"github.com/prometheus/prometheus/model/labels"
|
"github.com/prometheus/prometheus/model/labels"
|
||||||
"github.com/prometheus/prometheus/promql/parser"
|
"github.com/prometheus/prometheus/promql/parser"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
@ -43,11 +42,10 @@ type PyroscopeDatasource struct {
|
|||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
client ProfilingClient
|
client ProfilingClient
|
||||||
settings backend.DataSourceInstanceSettings
|
settings backend.DataSourceInstanceSettings
|
||||||
ac accesscontrol.AccessControl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPyroscopeDatasource creates a new datasource instance.
|
// NewPyroscopeDatasource creates a new datasource instance.
|
||||||
func NewPyroscopeDatasource(ctx context.Context, httpClientProvider httpclient.Provider, settings backend.DataSourceInstanceSettings, ac accesscontrol.AccessControl) (instancemgmt.Instance, error) {
|
func NewPyroscopeDatasource(ctx context.Context, httpClientProvider httpclient.Provider, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||||
ctxLogger := logger.FromContext(ctx)
|
ctxLogger := logger.FromContext(ctx)
|
||||||
opt, err := settings.HTTPClientOptions(ctx)
|
opt, err := settings.HTTPClientOptions(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -64,7 +62,6 @@ func NewPyroscopeDatasource(ctx context.Context, httpClientProvider httpclient.P
|
|||||||
httpClient: httpClient,
|
httpClient: httpClient,
|
||||||
client: NewPyroscopeClient(httpClient, settings.URL),
|
client: NewPyroscopeClient(httpClient, settings.URL),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
ac: ac,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
||||||
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Make sure PyroscopeDatasource implements required interfaces. This is important to do
|
// Make sure PyroscopeDatasource implements required interfaces. This is important to do
|
||||||
@ -64,16 +63,16 @@ func (s *Service) getInstance(ctx context.Context, pluginCtx backend.PluginConte
|
|||||||
return in, nil
|
return in, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideService(httpClientProvider *httpclient.Provider, ac accesscontrol.AccessControl) *Service {
|
func ProvideService(httpClientProvider *httpclient.Provider) *Service {
|
||||||
return &Service{
|
return &Service{
|
||||||
im: datasource.NewInstanceManager(newInstanceSettings(httpClientProvider, ac)),
|
im: datasource.NewInstanceManager(newInstanceSettings(httpClientProvider)),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newInstanceSettings(httpClientProvider *httpclient.Provider, ac accesscontrol.AccessControl) datasource.InstanceFactoryFunc {
|
func newInstanceSettings(httpClientProvider *httpclient.Provider) datasource.InstanceFactoryFunc {
|
||||||
return func(ctx context.Context, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
return func(ctx context.Context, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||||
return NewPyroscopeDatasource(ctx, httpClientProvider, settings, ac)
|
return NewPyroscopeDatasource(ctx, httpClientProvider, settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user