3

I'm attempting to add the google cloud profiler to my Django App Engine project, and would like to know where the best place to call it is?

Google Cloud Platform's documentation says to start the profiler as early as possible:

You should call start one time, and as early as possible in your application.

In a Django project, running on GCP App Engine Flex, where is the best place to call this so that 1. It is called only once, 2. It is not called on things like tests, migrations etc.

My initial thought was to place it in manage.py under execute_from_command_line, but I realised that this would call the profiler for simple things like manage.py test.

Django 2.2, App Engine Flexible, Gunicorn.

Henry George
  • 504
  • 6
  • 19

1 Answers1

0

I think this question might be helpful: Execute code when Django starts ONCE only?

The answer which suggests putting start up code in AppConfig sounds reasonable. It can make sure the code is executed at most once and avoid running code in simple management commands.