mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Remove specific stats from usage stats service * Create statscollector service * refactor * Update and move tests Mostly equivalent tests to before, but they've been divided over the two services and removed the behavior driven legacy from GoConvey to reduce the complexity of the tests. * Collect featuremgmr metrics (copied over from #47407) I removed the metrics registration from the feature manager in the merge and re-add them in this commit. Separated to make things easier to review.
82 lines
3.2 KiB
Go
82 lines
3.2 KiB
Go
package backgroundsvcs
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/api"
|
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
|
"github.com/grafana/grafana/pkg/infra/remotecache"
|
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
|
uss "github.com/grafana/grafana/pkg/infra/usagestats/service"
|
|
"github.com/grafana/grafana/pkg/infra/usagestats/statscollector"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/plugins/manager"
|
|
"github.com/grafana/grafana/pkg/registry"
|
|
"github.com/grafana/grafana/pkg/services/alerting"
|
|
"github.com/grafana/grafana/pkg/services/cleanup"
|
|
"github.com/grafana/grafana/pkg/services/dashboardsnapshots"
|
|
"github.com/grafana/grafana/pkg/services/guardian"
|
|
"github.com/grafana/grafana/pkg/services/live"
|
|
"github.com/grafana/grafana/pkg/services/live/pushhttp"
|
|
"github.com/grafana/grafana/pkg/services/ngalert"
|
|
"github.com/grafana/grafana/pkg/services/notifications"
|
|
plugindashboardsservice "github.com/grafana/grafana/pkg/services/plugindashboards/service"
|
|
"github.com/grafana/grafana/pkg/services/provisioning"
|
|
"github.com/grafana/grafana/pkg/services/rendering"
|
|
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
|
"github.com/grafana/grafana/pkg/services/serviceaccounts"
|
|
"github.com/grafana/grafana/pkg/services/store"
|
|
"github.com/grafana/grafana/pkg/services/thumbs"
|
|
"github.com/grafana/grafana/pkg/services/updatechecker"
|
|
)
|
|
|
|
func ProvideBackgroundServiceRegistry(
|
|
httpServer *api.HTTPServer, ng *ngalert.AlertNG, cleanup *cleanup.CleanUpService, live *live.GrafanaLive,
|
|
pushGateway *pushhttp.Gateway, notifications *notifications.NotificationService, pm *manager.PluginManager,
|
|
rendering *rendering.RenderingService, tokenService models.UserTokenBackgroundService, tracing tracing.Tracer,
|
|
provisioning *provisioning.ProvisioningServiceImpl, alerting *alerting.AlertEngine, usageStats *uss.UsageStats,
|
|
statsCollector *statscollector.Service, grafanaUpdateChecker *updatechecker.GrafanaService,
|
|
pluginsUpdateChecker *updatechecker.PluginsService, metrics *metrics.InternalMetricsService,
|
|
secretsService *secretsManager.SecretsService, remoteCache *remotecache.RemoteCache,
|
|
thumbnailsService thumbs.Service, StorageService store.StorageService,
|
|
// Need to make sure these are initialized, is there a better place to put them?
|
|
_ *dashboardsnapshots.Service, _ *alerting.AlertNotificationService,
|
|
_ serviceaccounts.Service, _ *guardian.Provider,
|
|
_ *plugindashboardsservice.DashboardUpdater,
|
|
) *BackgroundServiceRegistry {
|
|
return NewBackgroundServiceRegistry(
|
|
httpServer,
|
|
ng,
|
|
cleanup,
|
|
live,
|
|
pushGateway,
|
|
notifications,
|
|
rendering,
|
|
tokenService,
|
|
provisioning,
|
|
alerting,
|
|
pm,
|
|
grafanaUpdateChecker,
|
|
pluginsUpdateChecker,
|
|
metrics,
|
|
usageStats,
|
|
statsCollector,
|
|
tracing,
|
|
remoteCache,
|
|
secretsService,
|
|
StorageService,
|
|
thumbnailsService,
|
|
)
|
|
}
|
|
|
|
// BackgroundServiceRegistry provides background services.
|
|
type BackgroundServiceRegistry struct {
|
|
Services []registry.BackgroundService
|
|
}
|
|
|
|
func NewBackgroundServiceRegistry(services ...registry.BackgroundService) *BackgroundServiceRegistry {
|
|
return &BackgroundServiceRegistry{services}
|
|
}
|
|
|
|
func (r *BackgroundServiceRegistry) GetServices() []registry.BackgroundService {
|
|
return r.Services
|
|
}
|