סביבה גמישה של App Engine ב-Python

המאמר הזה מסביר איך לאתחל את Cloud Profiler באמצעות Python בסביבה הגמישה של App Engine.

דוגמת קוד

Python

מידע נוסף מופיע במאמרי העזרה של Profiler Python API.

כדי לבצע אימות ב-Profiler, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import googlecloudprofiler

# Profiler initialization. It starts a daemon thread which continuously
# collects and uploads profiles. Best done as early as possible.
try:
    # service and service_version can be automatically inferred when
    # running on App Engine. project_id must be set if not running
    # on GCP.
    googlecloudprofiler.start(verbose=3)
except (ValueError, NotImplementedError) as exc:
    print(exc)  # Handle errors here

המאמרים הבאים

כדי לחפש ולסנן דוגמאות קוד למוצרים אחרים של Google Cloud , אפשר להיעזר בGoogle Cloud דפדפן לדוגמה.