Skip to content

Commit

Permalink
Fix "no snapshot data found" error when `agent check <check> -m/--pro…
Browse files Browse the repository at this point in the history
…file-memory` (#19197)

* Fix namespaces for profile_memory

* changelog

* update comment

* fix lint
  • Loading branch information
keisku authored Dec 9, 2024
1 parent 0e37c69 commit 33ceb33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions datadog_checks_base/changelog.d/19197.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix "no snapshot data found" error when `agent check <check> --profile-memory`
8 changes: 7 additions & 1 deletion datadog_checks_base/datadog_checks/base/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,13 @@ def run(self):

enter_pdb(self.check, line=self.init_config['set_breakpoint'], args=(instance,))
elif self.should_profile_memory():
self.profile_memory(self.check, self.init_config, args=(instance,))
# self.init_config['profile_memory'] could be `/tmp/datadog-agent-memory-profiler*`
# that is generated by Datadog Agent.
# If we use `--m-dir` for `agent check` command, a hidden flag, it should be same as a given value.
namespaces = [self.init_config['profile_memory']]
for id in self.check_id.split(":"):
namespaces.append(id)
self.profile_memory(func=self.check, namespaces=namespaces, args=(instance,))
else:
self.check(instance)

Expand Down

0 comments on commit 33ceb33

Please sign in to comment.