Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not recalculate global entity id as string on each call #29934

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
6 changes: 6 additions & 0 deletions comp/core/tagger/common/entity_id_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ func BuildTaggerEntityID(entityID workloadmeta.EntityID) types.EntityID {
}

var globalEntityID = types.NewEntityID("internal", "global-entity-id")
var globalEntityIDString = globalEntityID.String()

// GetGlobalEntityID returns the entity ID that holds global tags
func GetGlobalEntityID() types.EntityID {
return globalEntityID
}

// GetGlobalEntityIDString returns, in a plain string format, the entity ID that holds global tags
func GetGlobalEntityIDString() string {
return globalEntityIDString
}
4 changes: 2 additions & 2 deletions comp/core/tagger/taggerimpl/local/fake_tagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (f *FakeTagger) SetTags(entityID string, source string, low, orch, high, st

// SetGlobalTags allows to set tags in store for the global entity
func (f *FakeTagger) SetGlobalTags(low, orch, high, std []string) {
f.SetTags(common.GetGlobalEntityID().String(), "static", low, orch, high, std)
f.SetTags(common.GetGlobalEntityIDString(), "static", low, orch, high, std)
}

// SetTagsFromInfo allows to set tags from list of TagInfo
Expand Down Expand Up @@ -112,7 +112,7 @@ func (f *FakeTagger) Tag(entityID string, cardinality types.TagCardinality) ([]s

// GlobalTags fake implementation
func (f *FakeTagger) GlobalTags(cardinality types.TagCardinality) ([]string, error) {
return f.Tag(common.GetGlobalEntityID().String(), cardinality)
return f.Tag(common.GetGlobalEntityIDString(), cardinality)
}

// AccumulateTagsFor fake implementation
Expand Down
8 changes: 4 additions & 4 deletions comp/core/tagger/taggerimpl/tagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,30 +338,30 @@ func (t *TaggerClient) AgentTags(cardinality types.TagCardinality) ([]string, er
func (t *TaggerClient) GlobalTags(cardinality types.TagCardinality) ([]string, error) {
t.mux.RLock()
if t.captureTagger != nil {
tags, err := t.captureTagger.Tag(taggercommon.GetGlobalEntityID().String(), cardinality)
tags, err := t.captureTagger.Tag(taggercommon.GetGlobalEntityIDString(), cardinality)
if err == nil && len(tags) > 0 {
t.mux.RUnlock()
return tags, nil
}
}
t.mux.RUnlock()
return t.defaultTagger.Tag(taggercommon.GetGlobalEntityID().String(), cardinality)
return t.defaultTagger.Tag(taggercommon.GetGlobalEntityIDString(), cardinality)
}

// globalTagBuilder queries global tags that should apply to all data coming
// from the agent and appends them to the TagsAccumulator
func (t *TaggerClient) globalTagBuilder(cardinality types.TagCardinality, tb tagset.TagsAccumulator) error {
t.mux.RLock()
if t.captureTagger != nil {
err := t.captureTagger.AccumulateTagsFor(taggercommon.GetGlobalEntityID().String(), cardinality, tb)
err := t.captureTagger.AccumulateTagsFor(taggercommon.GetGlobalEntityIDString(), cardinality, tb)

if err == nil {
t.mux.RUnlock()
return nil
}
}
t.mux.RUnlock()
return t.defaultTagger.AccumulateTagsFor(taggercommon.GetGlobalEntityID().String(), cardinality, tb)
return t.defaultTagger.AccumulateTagsFor(taggercommon.GetGlobalEntityIDString(), cardinality, tb)
}

// List the content of the defaulTagger
Expand Down
Loading