From 93a4ca729d4def1bfc749d3af023407a68863e29 Mon Sep 17 00:00:00 2001 From: Xueqin Cui <72771658+cuixq@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:19:15 +1100 Subject: [PATCH] fix(api): only start cloud profiler for test instance (#2941) Only start the cloud profiler for test instance so that we can continue our investigation on this without interrupting production release. --- gcp/api/server.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gcp/api/server.py b/gcp/api/server.py index 5fa29123e66..0dcee180fd5 100644 --- a/gcp/api/server.py +++ b/gcp/api/server.py @@ -1397,12 +1397,13 @@ def main(): setup_gcp_logging('api-backend') logging.getLogger().addFilter(trace_filter) - # Profiler initialization. It starts a daemon thread which continuously - # collects and uploads profiles. Best done as early as possible. - try: - googlecloudprofiler.start(service="osv-api-profiler") - except (ValueError, NotImplementedError) as e: - logging.error(e) + if get_gcp_project() == _TEST_INSTANCE: + # Profiler initialization. It starts a daemon thread which continuously + # collects and uploads profiles. Best done as early as possible. + try: + googlecloudprofiler.start(service="osv-api-profiler") + except (ValueError, NotImplementedError) as e: + logging.error(e) logging.getLogger().setLevel(logging.INFO)