From 33ceb33746246d137de8c152bf44afcf4b430dc7 Mon Sep 17 00:00:00 2001 From: Keisuke Umegaki <41987730+keisku@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:47:22 +0900 Subject: [PATCH] Fix "no snapshot data found" error when `agent check -m/--profile-memory` (#19197) * Fix namespaces for profile_memory * changelog * update comment * fix lint --- datadog_checks_base/changelog.d/19197.fixed | 1 + datadog_checks_base/datadog_checks/base/checks/base.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 datadog_checks_base/changelog.d/19197.fixed diff --git a/datadog_checks_base/changelog.d/19197.fixed b/datadog_checks_base/changelog.d/19197.fixed new file mode 100644 index 0000000000000..31cd6530b5639 --- /dev/null +++ b/datadog_checks_base/changelog.d/19197.fixed @@ -0,0 +1 @@ +Fix "no snapshot data found" error when `agent check --profile-memory` diff --git a/datadog_checks_base/datadog_checks/base/checks/base.py b/datadog_checks_base/datadog_checks/base/checks/base.py index c87b2cdb70479..9508dcc518dd4 100644 --- a/datadog_checks_base/datadog_checks/base/checks/base.py +++ b/datadog_checks_base/datadog_checks/base/checks/base.py @@ -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)