Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func New(cfg config.Database) Database {
}

type db struct {
Database
// metrics is the list of metric name (as a key) associated with their usage based on the different collector activated.
// This struct is our "database".
metrics map[string]*v1.Metric
Expand Down Expand Up @@ -115,6 +114,8 @@ type db struct {
partialMetricsUsageMutex sync.Mutex
}

var _ = Database(&db{})

func (d *db) DeleteMetric(name string) bool {
d.metricsMutex.Lock()
defer d.metricsMutex.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion source/grafana/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ func NewCollector(db database.Database, cfg config.GrafanaCollector) (async.Simp
}

type grafanaCollector struct {
async.SimpleTask
metricUsageClient *usageclient.Client
grafanaURL string
grafanaClient *grafanaapi.GrafanaHTTPAPI
logger *logrus.Entry
}

var _ async.SimpleTask = &grafanaCollector{}

func (c *grafanaCollector) Execute(ctx context.Context, _ context.CancelFunc) error {
hits, err := c.collectAllDashboardUID(ctx)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion source/labels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func NewCollector(db database.Database, cfg *config.LabelsCollector) (async.Simp
}

type labelCollector struct {
async.SimpleTask
promClient v1.API
db database.Database
metricUsageClient client.Client
Expand All @@ -60,6 +59,8 @@ type labelCollector struct {
logger *logrus.Entry
}

var _ async.SimpleTask = &labelCollector{}

func (c *labelCollector) Execute(ctx context.Context, _ context.CancelFunc) error {
now := time.Now()
start := now.Add(time.Duration(-c.period))
Expand Down
3 changes: 2 additions & 1 deletion source/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ func NewCollector(db database.Database, cfg config.MetricCollector) (async.Simpl
}

type metricCollector struct {
async.SimpleTask
client v1.API
db database.Database
period model.Duration
logger *logrus.Entry
}

var _ async.SimpleTask = &metricCollector{}

func (c *metricCollector) Execute(ctx context.Context, _ context.CancelFunc) error {
now := time.Now()
start := now.Add(time.Duration(-c.period))
Expand Down
3 changes: 2 additions & 1 deletion source/perses/perses.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ func NewCollector(db database.Database, cfg config.PersesCollector) (async.Simpl
}

type persesCollector struct {
async.SimpleTask
persesClient persesClientV1.DashboardInterface
metricUsageClient *usageclient.Client
persesURL string
logger *logrus.Entry
}

var _ async.SimpleTask = &persesCollector{}

func (c *persesCollector) Execute(_ context.Context, _ context.CancelFunc) error {
dashboards, err := c.persesClient.List("")
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion source/rules/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ func NewCollector(db database.Database, cfg *config.RulesCollector) (async.Simpl
}

type rulesCollector struct {
async.SimpleTask
promClient v1.API
metricUsageClient *usageclient.Client
promURL string
logger *logrus.Entry
retry uint
}

var _ async.SimpleTask = &rulesCollector{}

func (c *rulesCollector) Execute(ctx context.Context, _ context.CancelFunc) error {
result, err := c.getRules(ctx)
if err != nil {
Expand Down