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

feat: add labels from nri-winservices config as tags on UI. #1989

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion pkg/entity/register/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@ func (w *worker) send(ctx context.Context, batch map[entity.Key]fwrequest.Entity

var entities []entity.Fields
for _, r := range batch {
entities = append(entities, r.Data.Entity)
entity := r.Data.Entity
// Add labels to Metadata
if r.Definition.Labels != nil && len(r.Definition.Labels) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to check the nilness? If Labels is nil, len(r.Definition.Labels) will be 0, won't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to extract it in a short util func and add some unit tests? (Would improve coverage as well :))
But it's totally fine if we don't do this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the unit tests for this is an excellent point ;-)

for key, value := range r.Definition.Labels {
entity.Metadata[key] = value
}
}
entities = append(entities, entity)
}

responses := w.registerEntitiesWithRetry(ctx, entities)
Expand Down
Loading