Skip to content

Commit

Permalink
move store to static
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuminyi committed Dec 27, 2024
1 parent 11c64b9 commit b99434f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/cluster-agent/api/v2/series/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func newJobQueue(ctx context.Context) *jobQueue {
Limiter: rate.NewLimiter(rate.Limit(payloadProcessQPS), payloadProcessRateBurst),
},
)),
store: loadstore.NewEntityStore(ctx),
store: loadstore.GetWorkloadMetricStore(ctx),
isStarted: false,
}
go q.start(ctx)
Expand Down Expand Up @@ -113,6 +113,9 @@ func (jq *jobQueue) reportTelemetry(ctx context.Context) {
case <-ctx.Done():
return
case <-infoTicker.C:
if jq.store == nil {
continue
}
info := jq.store.GetStoreInfo()
statsResults := info.StatsResults
for _, statsResult := range statsResults {
Expand Down
15 changes: 15 additions & 0 deletions pkg/clusteragent/autoscaling/workload/loadstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,27 @@
package loadstore

import (
"context"
"strings"
"sync"

"github.com/DataDog/agent-payload/v5/gogen"
"github.com/DataDog/datadog-agent/pkg/util/kubernetes"
)

var (
WorkloadMetricStore Store
WorkloadMetricStoreOnce sync.Once
)

// GetWorkloadMetricStore returns the workload metric store, init once
func GetWorkloadMetricStore(ctx context.Context) Store {
WorkloadMetricStoreOnce.Do(func() {
WorkloadMetricStore = NewEntityStore(ctx)
})
return WorkloadMetricStore
}

// StoreInfo represents the store information which aggregates the entities to lowest level, i.e., container level
type StoreInfo struct {
currentTime Timestamp
Expand Down

0 comments on commit b99434f

Please sign in to comment.