Skip to content

Commit

Permalink
use sync.Once to avoid recalculating tagger.tagstore_use_composite_en…
Browse files Browse the repository at this point in the history
…tity_id on each call (#29211)
  • Loading branch information
adel121 authored and davidor committed Sep 27, 2024
1 parent b749e5f commit a3cb49e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/util/tagger/tagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
// Package tagger provides function to check if the tagger should use composite entity id and object store
package tagger

import "github.com/DataDog/datadog-agent/pkg/config"
import (
"sync"

pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
)

var useCompositeStore bool
var doOnce sync.Once

// ShouldUseCompositeStore indicates whether the tagger should use the default or composite implementation
// of entity ID and object store.
// TODO: remove this when we switch over fully to the composite implementation
func ShouldUseCompositeStore() bool {
return config.Datadog().GetBool("tagger.tagstore_use_composite_entity_id")
doOnce.Do(func() {
useCompositeStore = pkgconfigsetup.Datadog().GetBool("tagger.tagstore_use_composite_entity_id")
})
return useCompositeStore
}

0 comments on commit a3cb49e

Please sign in to comment.