-
Notifications
You must be signed in to change notification settings - Fork 77
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
Delete stale metric labels from BPF maps #99
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,6 +367,7 @@ func (l *loader) startHashMap( | |
select { | ||
case <-ticker.C: | ||
mapIter := liveMap.Iterate() | ||
labels := make([]map[string]string, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the map have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very unfortunately it does not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okie dokie |
||
for { | ||
// Use generic key,value so we can decode ourselves | ||
var ( | ||
|
@@ -398,12 +399,15 @@ func (l *loader) startHashMap( | |
} | ||
stringLabels := stringify(decodedKey) | ||
instrument.Set(ctx, int64(intVal), stringLabels) | ||
labels = append(labels, stringLabels) | ||
thisKvPair := KvPair{Key: stringLabels, Value: fmt.Sprint(intVal)} | ||
watcher.SendEntry(MapEntry{ | ||
Name: name, | ||
Entry: thisKvPair, | ||
}) | ||
} | ||
// remove any old labels that weren't in this last iteration of the HashMap | ||
instrument.Clean(labels) | ||
|
||
case <-ctx.Done(): | ||
// fmt.Println("got done in hashmap loop, returning") | ||
|
@@ -453,6 +457,8 @@ func (n *noop) Set( | |
) { | ||
} | ||
|
||
func (n *noop) Clean(_ []map[string]string) {} | ||
|
||
func createDir(ctx context.Context, path string, perm os.FileMode) error { | ||
file, err := os.Stat(path) | ||
if os.IsNotExist(err) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a permanent change and is it required? For the long term, I think it would be nice if we would only alter the upstream examples as little as absolutely needed for maintainability purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krisztianfekete no this is just for testing, I'm working off a VM in gcloud so have been pushing changes for tests. Will remove before merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tjons this PR looks good. Can you clean up so we can merge?