این صفحه نکات عیبیابی برای شروع کار با Performance Monitoring یا استفاده از ویژگیها و ابزارهای Performance Monitoring را ارائه میدهد.
بررسیهای اولیه برای عیبیابی
دو بررسی زیر، بهترین شیوههای کلی هستند که قبل از عیبیابی بیشتر به همه توصیه میشوند.
۱. پیامهای لاگ را برای رویدادهای عملکردی بررسی کنید
پیامهای لاگ خود را بررسی کنید تا مطمئن شوید که SDK Performance Monitoring ، رویدادهای عملکردی را ثبت میکند.
با اضافه کردن عنصر
<meta-data>به فایلAndroidManifest.xmlبرنامه خود، مانند زیر، ثبت اشکالزدایی را برای Performance Monitoring در زمان ساخت فعال کنید:<application> <meta-data android:name="firebase_performance_logcat_enabled" android:value="true" /> </application>پیامهای لاگ خود را برای هرگونه پیام خطا بررسی کنید.
Performance Monitoring پیامهای لاگ خود را با
FirebasePerformanceتگگذاری میکند. با استفاده از فیلتر کردن logcat، میتوانید با اجرای دستور زیر، ردیابی مدت زمان و لاگ درخواستهای شبکه HTTP/S را بهطور خاص مشاهده کنید:adb logcat -s FirebasePerformance
انواع گزارشهای زیر را که نشان میدهند Performance Monitoring در حال ثبت رویدادهای عملکردی است، بررسی کنید:
-
Logging trace metric: TRACE_NAME , FIREBASE_PERFORMANCE_CONSOLE_URL -
Logging network request trace: URL
-
برای مشاهده دادههای خود در کنسول Firebase، روی URL کلیک کنید. ممکن است چند لحظه طول بکشد تا دادهها در داشبورد بهروزرسانی شوند.
اگر برنامه شما رویدادهای عملکرد را ثبت نمیکند، نکات عیبیابی را مرور کنید.
۲. داشبورد وضعیت فایربیس را بررسی کنید
در صورت وجود قطعی شناختهشده برای Firebase یا برای Performance Monitoring داشبورد وضعیت Firebase را بررسی کنید.
شروع کار با Performance Monitoring
اگر تازه کار با Performance Monitoring ( iOS+ | اندروید | وب ) را شروع کردهاید، نکات عیبیابی زیر میتواند به شما در رفع مشکلاتی که شامل شناسایی SDK توسط Firebase یا نمایش اولین دادههای عملکرد شما در کنسول Firebase میشود، کمک کند.
فایربیس میتواند با دریافت اطلاعات رویداد (مانند تعاملات برنامه) از برنامه شما، تشخیص دهد که آیا با موفقیت SDK Performance Monitoring را به برنامه خود اضافه کردهاید یا خیر. معمولاً ظرف 10 دقیقه پس از شروع برنامه، داشبورد عملکرد کنسول Firebase پیام "SDK شناسایی شد" را نمایش میدهد. سپس، ظرف 30 دقیقه، داشبورد دادههای پردازش شده اولیه را نمایش میدهد.
اگر بیش از 10 دقیقه از اضافه کردن آخرین نسخه SDK به برنامهتان گذشته است و هنوز هیچ تغییری مشاهده نمیکنید، پیامهای گزارش خود را بررسی کنید تا مطمئن شوید که Performance Monitoring در حال ثبت رویدادها است. مراحل عیبیابی مناسب را که در زیر توضیح داده شده است، برای عیبیابی پیام تأخیر در تشخیص SDK امتحان کنید.
مطمئن شوید که از Performance Monitoring Android SDK نسخه ۱۹.۱.۰ یا بالاتر (یا Firebase BoM نسخه ۲۶.۳.۰ یا بالاتر) استفاده میکنید، به یادداشت انتشار مراجعه کنید.
اگر هنوز در حال توسعه محلی هستید، سعی کنید رویدادهای بیشتری برای جمعآوری دادهها ایجاد کنید:
- با تغییر چندین باره برنامه بین پسزمینه و پیشزمینه، تعامل با برنامه با پیمایش در صفحههای مختلف و/یا ایجاد درخواستهای شبکه، رویدادها را ایجاد کنید.
مطمئن شوید که فایل پیکربندی Firebase شما (
google-services.json) به درستی به برنامه اضافه شده است و فایل را تغییر ندادهاید. به طور خاص، موارد زیر را بررسی کنید:نام فایل پیکربندی با کاراکترهای اضافی مانند
(2)اضافه نشده است.فایل پیکربندی در دایرکتوری ماژول (سطح برنامه) برنامه شما قرار دارد.
شناسه برنامه اندروید فایربیس (
mobilesdk_app_id) که در فایل پیکربندی ذکر شده است، برای برنامه شما صحیح است. شناسه برنامه فایربیس خود را در کارت برنامههای شما (Your apps) در پروژه (Project settings ) پیدا کنید.
اگر به نظر میرسد فایل پیکربندی برنامه شما مشکلی دارد، موارد زیر را امتحان کنید:
فایل پیکربندی که در حال حاضر در برنامه خود دارید را حذف کنید.
برای دانلود یک فایل پیکربندی جدید و افزودن آن به برنامه اندروید خود، این دستورالعملها را دنبال کنید.
اگر SDK رویدادها را ثبت میکند و به نظر میرسد همه چیز به درستی تنظیم شده است، اما هنوز پیام تشخیص SDK یا دادههای پردازش شده را مشاهده نمیکنید (پس از 10 دقیقه)، با پشتیبانی Firebase تماس بگیرید .
تنظیمات افزونه Performance Monitoring Gradle را به صورت زیر بررسی کنید:
مطمئن شوید که افزونه را به درستی اضافه کردهاید . به طور خاص، موارد زیر را بررسی کنید:
- شما افزونه (
) را در فایلapply plugin: 'com.google.firebase.firebase-perf' build.gradleماژول (app-level) خود اضافه کردید. - شما وابستگی classpath را برای افزونه (
) در فایلclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradleسطح پروژه خود وارد کردهاید.
- شما افزونه (
مطمئن شوید که افزونه از طریق هیچ یک از پرچمهای زیر غیرفعال نشده باشد :
-
instrumentationEnabledدر فایلbuild.gradleماژول شما (در سطح برنامه) -
firebasePerformanceInstrumentationEnabledدر فایلgradle.propertiesشما
-
بررسی کنید که SDK نظارت بر عملکرد از طریق هیچ یک از پرچمهای زیر در فایل
AndroidManifest.xmlشما Performance Monitoring نشده باشد :-
firebase_performance_collection_enabled -
firebase_performance_collection_deactivated
-
مطمئن شوید که Performance Monitoring در زمان اجرا غیرفعال نباشد .
اگر نمیتوانید چیزی را که در برنامهتان غیرفعال شده است پیدا کنید، با پشتیبانی Firebase تماس بگیرید .
Performance Monitoring دادههای رویداد عملکرد را قبل از نمایش در داشبورد عملکرد، پردازش میکند.
اگر بیش از ۲۴ ساعت از نمایش پیام "SDK شناسایی شد" گذشته است و هنوز دادهای مشاهده نمیکنید، داشبورد وضعیت Firebase را بررسی کنید تا مطمئن شوید که قطعی وجود دارد. اگر قطعی وجود نداشت، با پشتیبانی Firebase تماس بگیرید .
عیب یابی عمومی
اگر SDK را با موفقیت اضافه کردهاید و Performance Monitoring در برنامه خود استفاده میکنید، نکات عیبیابی زیر میتواند به رفع مشکلات عمومی مربوط به ویژگیها و ابزارهای Performance Monitoring کمک کند.
اگر پیامهای گزارش مربوط به رویدادهای عملکرد را نمیبینید، مراحل عیبیابی زیر را امتحان کنید:
تنظیمات افزونه Performance Monitoring Gradle را به صورت زیر بررسی کنید:
مطمئن شوید که افزونه را به درستی اضافه کردهاید . به طور خاص، موارد زیر را بررسی کنید:
- شما افزونه (
) را در فایلapply plugin: 'com.google.firebase.firebase-perf' build.gradleماژول (app-level) خود اضافه کردید. - شما وابستگی classpath را برای افزونه (
) در فایلclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradleسطح پروژه خود وارد کردهاید.
- شما افزونه (
مطمئن شوید که افزونه از طریق هیچ یک از پرچمهای زیر غیرفعال نشده باشد :
-
instrumentationEnabledدر فایلbuild.gradleماژول شما (در سطح برنامه) -
firebasePerformanceInstrumentationEnabledدر فایلgradle.propertiesشما
-
بررسی کنید که SDK نظارت بر عملکرد از طریق هیچ یک از پرچمهای زیر در فایل
AndroidManifest.xmlشما Performance Monitoring نشده باشد :-
firebase_performance_collection_enabled -
firebase_performance_collection_deactivated
-
مطمئن شوید که Performance Monitoring در زمان اجرا غیرفعال نباشد .
اگر نمیتوانید چیزی را که در برنامهتان غیرفعال شده است پیدا کنید، با پشتیبانی Firebase تماس بگیرید .
اگر دادههای مربوط به ردیابی رندر صفحه نمایش را از دست میدهید، مراحل عیبیابی زیر را امتحان کنید:
مطمئن شوید که از آخرین نسخه Android SDK (نسخه ۲۲.۰.۴) استفاده میکنید. ردیابیهای رندر صفحه فقط با نسخه ۱۵.۲.۰ یا بالاتر در دسترس هستند.
مطمئن شوید که شتابدهنده سختافزاری را برای یک صفحه نمایش به صورت دستی غیرفعال نکردهاید.
مطمئن شوید که از DexGuard یا Jack استفاده نمیکنید. Performance Monitoring با این ابزارهای زنجیرهای سازگار نیست.
دکسگارد (DexGuard) جمعآوری خودکار ردپاهای شروع برنامه، ردپاهای برنامه در پیشزمینه و ردپاهای برنامه در پسزمینه را غیرفعال میکند. با این حال، اگر برنامه شما از دکسگارد استفاده میکند، هرگونه ردپا از کدهای سفارشی باید به طور عادی رفتار کند.
جک منسوخ شده است و عموماً نباید در برنامه شما استفاده شود.
آیا دادههای عملکرد را برای ردیابیهای جمعآوریشده خودکار مشاهده میکنید اما برای ردیابیهای کد سفارشی خیر ؟ مراحل عیبیابی زیر را امتحان کنید:
اگر ردیابی کدهای سفارشی را از طریق Trace API انجام دادهاید، تنظیمات ردیابیها، به ویژه موارد زیر را بررسی کنید:
- نامهای مربوط به ردیابی کدهای سفارشی و معیارهای سفارشی باید الزامات زیر را داشته باشند: بدون فاصلهی خالی در ابتدا یا انتهای نام، بدون کاراکتر زیرخط (
_) در ابتدای نام، و حداکثر طول نام ۳۲ کاراکتر. - همه ردیابیها باید شروع و متوقف شوند. هر ردیابی که شروع نشده، متوقف نشده یا قبل از شروع متوقف شده باشد، ثبت نخواهد شد.
- نامهای مربوط به ردیابی کدهای سفارشی و معیارهای سفارشی باید الزامات زیر را داشته باشند: بدون فاصلهی خالی در ابتدا یا انتهای نام، بدون کاراکتر زیرخط (
اگر از طریق نمادگذاری
@AddTraceردیابی کدهای سفارشی را انجام دادهاید، تنظیمات افزونه Performance Monitoring Gradle را بررسی کنید:مطمئن شوید که افزونه را به درستی اضافه کردهاید . به طور خاص، موارد زیر را بررسی کنید:
- شما افزونه (
) را در فایلapply plugin: 'com.google.firebase.firebase-perf' build.gradleماژول (app-level) خود اضافه کردید. - شما وابستگی classpath را برای افزونه (
) در فایلclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradleسطح پروژه خود وارد کردهاید.
- شما افزونه (
مطمئن شوید که افزونه از طریق هیچ یک از پرچمهای زیر غیرفعال نشده باشد :
-
instrumentationEnabledدر فایلbuild.gradleماژول شما (در سطح برنامه) -
firebasePerformanceInstrumentationEnabledدر فایلgradle.propertiesشما
-
پیامهای گزارش خود را بررسی کنید تا مطمئن شوید که Performance Monitoring رد کدهای سفارشی مورد انتظار را ثبت میکند.
اگر Performance Monitoring در حال ثبت رویدادها است، اما پس از 24 ساعت هیچ دادهای نمایش داده نمیشود، با پشتیبانی Firebase تماس بگیرید .
اگر دادههای درخواست شبکه را از دست میدهید، مراحل عیبیابی زیر را امتحان کنید:
برای برنامههای اندروید، افزونهی Performance Monitoring Gradle ابزاری را فعال میکند که مانیتورینگ خودکار درخواستهای شبکه HTTP/S را فراهم میکند. موارد زیر را بررسی کنید:
مطمئن شوید که افزونه را به درستی اضافه کردهاید . به طور خاص، موارد زیر را بررسی کنید:
- شما افزونه (
) را در فایلapply plugin: 'com.google.firebase.firebase-perf' build.gradleماژول (app-level) خود اضافه کردید. - شما وابستگی classpath را برای افزونه (
) در فایلclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradleسطح پروژه خود وارد کردهاید.
- شما افزونه (
مطمئن شوید که افزونه از طریق هیچ یک از پرچمهای زیر غیرفعال نشده باشد :
-
instrumentationEnabledدر فایلbuild.gradleماژول شما (در سطح برنامه) -
firebasePerformanceInstrumentationEnabledدر فایلgradle.propertiesشما
-
بررسی ناسازگاری کتابخانه شبکه. Performance Monitoring به طور خودکار معیارهایی را برای درخواستهای شبکهای که از کتابخانههای شبکه زیر استفاده میکنند، جمعآوری میکند: OkHttp 3.xx، URLConnection جاوا و Apache HttpClient.
توجه داشته باشید که میتوانید نظارت سفارشی را برای درخواستهای شبکه اضافه کنید .
از موارد زیر آگاه باشید:
بسته به رفتار کد شما و کتابخانههای شبکهای که توسط کد شما استفاده میشوند، Performance Monitoring ممکن است فقط درخواستهای شبکهای که تکمیل شدهاند را گزارش دهد. این بدان معناست که اتصالات HTTP/S که باز ماندهاند ممکن است گزارش نشوند.
Performance Monitoring با DexGuard و Jack سازگار نیست.
- دکسگارد (DexGuard) نظارت بر درخواستهای شبکه HTTP/S را غیرفعال میکند.
- جک منسوخ شده است و عموماً نباید در برنامه شما استفاده شود.
Performance Monitoring درخواستهای شبکه با هدرهای
Content-TypeHeaders) نامعتبر را گزارش نمیکند. با این حال، درخواستهای شبکه بدون هدرهایContent-TypeHeaders) همچنان پذیرفته میشوند.
درباره نحوه جمعآوری دادههای درخواست شبکه Performance Monitoring تحت الگوهای URL بیشتر بدانید.
همچنین میتوانید الگوهای URL سفارشی را امتحان کنید!
سوالات متداول
ما در ادامهی معرفی هشدارهای اخیرمان، «مشکلات مهم» را با «هشدارهای اخیر» جایگزین کردیم. این هشدارها به طور خودکار هنگام عبور از آستانههای تعیینشده توسط شما، به شما اطلاع میدهند. اکنون «مشکلات» منسوخ شده و با هشدارها جایگزین شدهاند.
انتخابگر برنامهها در بالای کارت عملکرد، ورودیهای هشدار را در زیر هشدارهای اخیر فیلتر میکند. فقط سه هشدار اخیر برای برنامه (های) انتخاب شده نمایش داده میشوند.
برای کسب اطلاعات بیشتر در مورد هشدارها، به تنظیم هشدارها برای مشکلات عملکرد مراجعه کنید.
Performance Monitoring از هشدارهایی برای معیارهایی که از آستانههای تعریفشده تجاوز میکنند، پشتیبانی میکند. برای جلوگیری از سردرگمی با این آستانههای قابل تنظیم برای معیارهای عملکرد، قابلیت پیکربندی آستانهها برای مشکلات را حذف کردیم.
ما صفحات Details و Metrics را با یک رابط کاربری (UI) متمرکز و بازطراحیشده جایگزین کردیم تا نحوه عیبیابی مشکلات را بهبود بخشیم. این رابط کاربری عیبیابی جدید، همان قابلیتهای اصلی Details و Metrics را ارائه میدهد. برای کسب اطلاعات بیشتر در مورد عیبیابی، به بخش «مشاهده دادههای بیشتر برای یک ردیابی خاص» مراجعه کنید.
Performance Monitoring دادههای عملکرد را از دستگاههای کاربر برنامه شما جمعآوری میکند. اگر برنامه شما کاربران زیادی دارد یا اگر برنامه حجم زیادی از فعالیتهای عملکردی را تولید میکند، Performance Monitoring ممکن است جمعآوری دادهها را به زیرمجموعهای از دستگاهها محدود کند تا تعداد رویدادهای پردازششده را کاهش دهد. این محدودیتها به اندازهای زیاد هستند که حتی با رویدادهای کمتر، مقادیر معیار همچنان نمایانگر تجربه برنامه کاربر شما باشند.
برای مدیریت حجم دادههایی که جمعآوری میکنیم، Performance Monitoring از گزینههای نمونهگیری زیر استفاده میکند:
محدود کردن سرعت روی دستگاه : برای جلوگیری از ارسال ناگهانی ردیابیها توسط دستگاه، تعداد ردیابیهای کد و درخواست شبکه ارسال شده از یک دستگاه را به ۳۰۰ رویداد در هر ۱۰ دقیقه محدود میکنیم. این رویکرد، دستگاه را از ابزارهای حلقهای که میتوانند حجم زیادی از دادههای عملکرد را ارسال کنند، محافظت میکند و از تحریف اندازهگیریهای عملکرد توسط یک دستگاه واحد جلوگیری میکند.
نمونهبرداری پویا : Performance Monitoring روزانه تعداد محدودی از رد کد و رد درخواست شبکه را به ازای هر برنامه در بین تمام کاربران برنامه جمعآوری میکند. یک نرخ نمونهبرداری پویا روی دستگاهها (با استفاده از Firebase Remote Config ) واکشی میشود تا مشخص شود که آیا یک دستگاه تصادفی باید ردها را ضبط و ارسال کند یا خیر. دستگاهی که برای نمونهبرداری انتخاب نشده است، هیچ رویدادی ارسال نمیکند. نرخ نمونهبرداری پویا مختص برنامه است و تنظیم میشود تا اطمینان حاصل شود که حجم کلی دادههای جمعآوریشده کمتر از حد مجاز باقی میماند.
پروژههایی که ادغام BigQuery را فعال کردهاند، محدودیت بیشتری برای تعداد ردیابی درخواستهای شبکه دریافت میکنند.
جلسات کاربر، دادههای اضافی و دقیقی را از دستگاه کاربر ارسال میکنند که به منابع بیشتری برای ضبط و ارسال دادهها نیاز دارد. برای به حداقل رساندن تأثیر جلسات کاربر، Performance Monitoring ممکن است تعداد جلسات را نیز محدود کند.
محدود کردن نرخ سمت سرور : برای اطمینان از اینکه برنامهها از حد نمونهبرداری تجاوز نمیکنند، Performance Monitoring ممکن است از نمونهبرداری سمت سرور برای حذف برخی از رویدادهای دریافتی از دستگاهها استفاده کند. اگرچه این نوع محدود کردن، اثربخشی معیارهای ما را تغییر نمیدهد، اما ممکن است باعث تغییرات جزئی در الگو، از جمله موارد زیر، شود:
- تعداد ردپاها میتواند با تعداد دفعاتی که یک قطعه کد اجرا شده است، متفاوت باشد.
- ردپاهایی که در کد به هم نزدیک هستند، ممکن است هر کدام تعداد نمونههای متفاوتی داشته باشند.
ما تب «مسائل» (Problems) را با «هشدارها» (Alerts) جایگزین کردیم، که به طور خودکار هنگام عبور از آستانههای تعیینشده به شما اطلاع میدهد. دیگر نیازی نیست کنسول Firebase را به صورت دستی بررسی کنید تا وضعیت یک آستانه را تعیین کنید. برای کسب اطلاعات در مورد هشدارها، به «تنظیم هشدارها برای مشکلات عملکرد» مراجعه کنید.
ما بخش Performance Monitoring کنسول Firebase را دوباره طراحی کردهایم تا تب داشبورد ، معیارهای کلیدی و تمام ردیابیهای شما را در یک فضا نمایش دهد. به عنوان بخشی از طراحی مجدد، صفحات On device و Network را حذف کردیم.
جدول ردیابیها در پایین برگه داشبورد، تمام اطلاعات مشابه با برگههای «دستگاه روشن» و «شبکه» را دارد، اما برخی ویژگیهای اضافه شده، از جمله امکان مرتبسازی ردیابیها بر اساس درصد تغییر برای یک معیار خاص. برای مشاهده تمام معیارها و دادههای یک ردیابی خاص، روی نام ردیابی در جدول ردیابیها کلیک کنید.
ردپاهای خود را در زیربرگههای جدول ردپاها مشاهده کنید:
- ردیابی درخواستهای شبکه (هم از قبل آماده و هم سفارشی) — زیربرگه درخواستهای شبکه
- ردپاهای کد سفارشی — زیربرگه ردپاهای سفارشی
- شروع برنامه، ردیابی برنامه در پیشزمینه، ردیابی برنامه در پسزمینه — زیربرگه ردیابیهای سفارشی
- ردیابیهای رندر صفحه نمایش — زیربرگه رندر صفحه نمایش
- ردیابی بارگذاری صفحه — زیربرگه بارگذاری صفحه
برای جزئیات بیشتر در مورد جدول ردگیریها و مشاهده معیارها و دادهها، به صفحه نمای کلی کنسول ( iOS+ | اندروید | وب ) مراجعه کنید.
فریمهای رندر کند و فریمهای فریز شده با نرخ نوسازی فرضی ۶۰ هرتز دستگاه محاسبه میشوند. اگر نرخ نوسازی دستگاه کمتر از ۶۰ هرتز باشد، هر فریم زمان رندر کندتری خواهد داشت زیرا فریمهای کمتری در هر ثانیه رندر میشوند. زمان رندر کندتر میتواند باعث گزارش فریمهای کند یا فریز شده بیشتری شود زیرا فریمهای بیشتری کندتر رندر میشوند یا فریز میشوند. با این حال، اگر نرخ نوسازی دستگاه بالاتر از ۶۰ هرتز باشد، هر فریم زمان رندر سریعتری خواهد داشت. این میتواند باعث گزارش فریمهای کند یا فریز شده کمتری شود. این یک محدودیت فعلی در SDK Performance Monitoring است.
برای مشاهده عملکرد قطعات علاوه بر فعالیت برنامه، مطمئن شوید که برنامه شما از Performance Monitoring Android SDK نسخه 20.1.0 یا بالاتر استفاده میکند. برای کسب اطلاعات بیشتر، به Add Performance Monitoring to your app مراجعه کنید.
هر یک از ردیابیهای قطعه و فعالیت بر اساس نام کلاس آن است که در برنامه شما تعریف شده است. هر یک از ردیابیهای صفحه نمایش شامل پیشوند st و به دنبال آن نام کلاس است. در کنسول Firebase، پیشوند حذف میشود. برای کسب اطلاعات بیشتر، به بخش «اطلاعات در مورد دادههای عملکرد رندر صفحه نمایش (برنامههای اپل و اندروید)» مراجعه کنید.
Performance Monitoring نمونهبرداری از رویدادها را در تمام رویدادهای جمعآوریشده روی یک دستگاه انجام میدهد. این رویکرد به ما امکان میدهد حداقل رویدادهای مورد نیاز را از دستگاههای کاربر جمعآوری کنیم تا معیارهای عملکرد را ارائه دهیم.
Performance Monitoring به شما امکان میدهد هشدارهایی را برای معیارهایی که برایتان مهم هستند تنظیم کنید. برای ردیابیهای رندر صفحه نمایش تولید شده، میتوانید هشدارهایی را تنظیم کنید تا وقتی درصد فریمهای کند و ثابت از آستانهای که تعیین کردهاید فراتر میرود، به شما اطلاع دهند.
Performance Monitoring برای اندروید از ابزار بایتکد برای ارائه برخی ویژگیهای آماده مانند نظارت بر درخواستهای شبکه HTTP/S استفاده میکند. به عنوان بخشی از کامپایل، این فرآیند نیاز به تکرار در تمام کلاسهای برنامه شما (از جمله وابستگیها) دارد تا کدی را که در اندازهگیری عملکرد درخواست شبکه برنامه شما بسیار مهم است، ابزاربندی کند.
در اینجا به برخی از عوامل کلیدی که باعث افزایش زمان ساخت میشوند اشاره میکنیم:
- تعداد کلاسها یا فایلها
- اندازه هر یک از آن کلاسها (تعداد خطوط کد)
- پیکربندی دستگاه شما
- ساخت اولیه در مقابل ساخت بعدی (ساختهای بعدی معمولاً سریعتر از ساخت اولیه هستند)
برای بهینهسازی زمان ساخت، ماژولار کردن کد خود را در نظر بگیرید.
با شروع از نسخه ۱.۳.۳ افزونه Performance Monitoring ، ما بر ایجاد پیشرفتهای قابل توجه در پردازش ساخت افزایشی و ذخیرهسازی ورودیهای کتابخانه تمرکز کردهایم. برای دریافت جدیدترین پیشرفتهای زمان ساخت، حتماً از آخرین نسخه افزونه (نسخه ۲.۰.۲) استفاده کنید .
توجه داشته باشید که اگر میخواهید از زمان طولانی ساخت جلوگیری کنید، میتوانید افزونهی Performance Monitoring را برای نسخههای اشکالزدایی (debug builds) خود به صورت محلی غیرفعال کنید . با این حال، این رویکرد برای نسخههای عملیاتی (production builds) توصیه نمیشود، زیرا میتواند منجر به از دست رفتن اندازهگیریهای عملکرد برای درخواستهای شبکه در برنامه شما شود.
Performance Monitoring برای اندروید از ابزار بایتکد برای ارائه برخی ویژگیهای آماده مانند نظارت بر درخواستهای شبکه HTTP/S استفاده میکند. به عنوان بخشی از کامپایل، این فرآیند نیاز به تکرار در تمام کلاسهای برنامه شما (از جمله وابستگیها) دارد تا کدی را که در اندازهگیری عملکرد درخواست شبکه برنامه شما بسیار مهم است، ابزاربندی کند.
اگر پس از ادغام با افزونه Performance Monitoring با خطاهای ساخت مانند JSR/RET are not supported with computeFrames option یا خطاهای مشابه مواجه شدید، ممکن است به این دلیل باشد که شما به کتابخانهای وابسته هستید که با افزونه Performance Monitoring Gradle سازگار نیست.
برای حل این مشکل، میتوانید با دنبال کردن مراحل زیر، کلاسها/کتابخانههای ناسازگار را از ابزارسازی مستثنی کنید:
- افزونهی Performance Monitoring Gradle را به آخرین نسخه بهروزرسانی کنید (حداقل نسخه ۱.۴.۰ ).
- نسخه افزونه Android Gradle خود را به نسخه 7.2.0 یا جدیدتر ارتقا دهید.
- برای جلوگیری از استفاده از کلاسها/کتابخانههای ناسازگار، پرچم زیر را به فایل
build.gradleماژول (سطح برنامه) خود اضافه کنید: برای کسب اطلاعات بیشتر در مورد ویژگیandroid { // ... androidComponents { onVariants(selector().all(), { instrumentation.excludes.add("example.incompatible.library") }) } }
excludeاز APIInstrumentationافزونه Android Gradle، به Instrumentation مراجعه کنید.
لطفاً هنگام مواجهه با خطاهای ساخت ناشی از کتابخانههای ناسازگار، یک مشکل در گیتهاب ثبت کنید تا بتوان آنها را از ابزاربندی در افزونه Performance Monitoring نیز مستثنی کرد.
اگر ادغام BigQuery را برای Firebase Performance Monitoring فعال کرده باشید، دادههای شما ۱۲ تا ۲۴ ساعت پس از پایان روز (به وقت اقیانوس آرام) به BigQuery صادر میشوند.
برای مثال، دادههای مربوط به ۱۹ آوریل در BigQuery در تاریخ ۲۰ آوریل بین ساعت ۱۲ ظهر تا نیمهشب (تمام تاریخها و زمانها به وقت اقیانوس آرام هستند) در دسترس خواهند بود.
Near real-time data processing and display
Firebase Performance Monitoring processes collected performance data as it comes in, which results in near real-time data display in the Firebase console. Processed data displays in the console within a few minutes of its collection, hence the term "near real-time".
To take advantage of near real-time data processing, make sure your app uses a real-time compatible SDK version .
To take advantage of near real-time data processing, you only need to make sure that your app uses a Performance Monitoring SDK version that's compatible with real-time data processing.
These are the real-time compatible SDK versions:
- iOS — v7.3.0 or later
- tvOS — v8.9.0 or later
- Android — v19.0.10 or later (or Firebase Android BoM v26.1.0 or later)
- Web — v7.14.0 or later
Note that we always recommend using the latest version of SDK, but any version listed above will enable Performance Monitoring to process your data in near real time.
These are the SDK versions compatible with real-time data processing:
- iOS — v7.3.0 or later
- tvOS — v8.9.0 or later
- Android — v19.0.10 or later (or Firebase Android BoM v26.1.0 or later)
- Web — v7.14.0 or later
Note that we always recommend using the latest version of SDK, but any version listed above will enable Performance Monitoring to process your data in near real time.
If your app doesn't use a real-time compatible SDK version, you will still see all your app's performance data in the Firebase console. However, the display of performance data will be delayed by roughly 36 hours from the time of its collection.
Yes! Regardless of which SDK version an app instance uses, you'll see performance data from all your users.
However, if you're looking at recent data (less than roughly 36 hours old), then the displayed data is from users of app instances using a real-time compatible SDK version. The non-recent data, though, includes performance data from all versions of your app.
Contacting Firebase Support
If you reach out to Firebase Support , always include your Firebase App ID. Find your Firebase App ID in the Your apps card of your Project settings .
،This page provides troubleshooting tips for getting started with Performance Monitoring or using Performance Monitoring features and tooling.
First checks for troubleshooting
The following two checks are general best practices recommended for anyone before further troubleshooting.
1. Check log messages for performance events
Check your log messages to be sure that the Performance Monitoring SDK is capturing performance events.
Enable debug logging for Performance Monitoring at build time by adding a
<meta-data>element to your app'sAndroidManifest.xmlfile, like so:<application> <meta-data android:name="firebase_performance_logcat_enabled" android:value="true" /> </application>Check your log messages for any error messages.
Performance Monitoring tags its log messages with
FirebasePerformance. Using logcat filtering, you can specifically view duration trace and HTTP/S network request logging by running the following command:adb logcat -s FirebasePerformance
Check for the following types of logs which indicate that Performance Monitoring is logging performance events:
-
Logging trace metric: TRACE_NAME , FIREBASE_PERFORMANCE_CONSOLE_URL -
Logging network request trace: URL
-
Click on the URL to view your data in the Firebase console. It may take a few moments for the data to update in the dashboard.
If your app isn't logging performance events, review the troubleshooting tips .
2. Check the Firebase Status Dashboard
Check the Firebase Status Dashboard in case there is a known outage for Firebase or for Performance Monitoring .
Getting started with Performance Monitoring
If you're getting started with Performance Monitoring ( iOS+ | Android | Web ), the following troubleshooting tips can help with issues that involve Firebase detecting the SDK or displaying your first performance data in the Firebase console.
Firebase can detect if you've successfully added the Performance Monitoring SDK to your app when it receives event information (like app interactions) from your app. Usually within 10 minutes of starting your app, the Performance dashboard of the Firebase console displays an "SDK detected" message. Then, within 30 minutes, the dashboard displays the initial processed data.
If it's been more than 10 minutes since you added the latest version of SDK to your app, and you're still not seeing any change, check your log messages to make sure that Performance Monitoring is logging events. Try the appropriate troubleshooting steps as described below to troubleshoot a delayed SDK detection message.
Make sure that you're using the Performance Monitoring Android SDK 19.1.0 or later (or Firebase BoM 26.3.0 or later), see Release Note .
If you're still developing locally, try generating more events for data collection:
- Generate events by switching your app between background and foreground several times, interacting with your app by navigating across screens, and/or triggering network requests.
Make sure that your Firebase configuration file (
google-services.json) is correctly added to your app and that you haven't modified the file. Specifically, check the following:The config file name isn't appended with additional characters, like
(2).The config file is in the module (app-level) directory of your app.
The Firebase Android App ID (
mobilesdk_app_id) listed in the config file is correct for your app. Find your Firebase App ID in the Your apps card of your Project settings .
If anything seems wrong with the config file in your app, try the following:
Delete the config file that you currently have in your app.
Follow these instructions to download a new config file and add it to your Android app.
If the SDK is logging events and everything seems to be set up correctly, but you're still not seeing the SDK detection message or processed data (after 10 minutes), contact Firebase Support .
Check the setup of the Performance Monitoring Gradle plugin, as follows:
Make sure that you added the plugin correctly. Specifically, check the following:
- You added the plugin (
) in your module (app-level)apply plugin: 'com.google.firebase.firebase-perf' build.gradlefile. - You included the classpath dependency for the plugin (
) in your project-levelclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradlefile.
- You added the plugin (
Make sure that the plugin is not disabled through either of the following flags:
-
instrumentationEnabledin your module (app-level)build.gradlefile -
firebasePerformanceInstrumentationEnabledin yourgradle.propertiesfile
-
Check that the Performance Monitoring SDK is not disabled through either of the following flags in your
AndroidManifest.xmlfile:-
firebase_performance_collection_enabled -
firebase_performance_collection_deactivated
-
Make sure that Performance Monitoring is not disabled at runtime .
If you can't find anything that's disabled in your app, contact Firebase Support .
Performance Monitoring processes performance event data before displaying it in the Performance dashboard .
If it's been more than 24 hours since the "SDK detected" message appeared , and you're still not seeing data, then check the Firebase Status Dashboard in case there is a known outage. If there is no outage, contact Firebase Support .
عیب یابی عمومی
If you've successfully added the SDK and are using Performance Monitoring in your app, the following troubleshooting tips can help with general issues that involve Performance Monitoring features and tooling.
If you're not seeing log messages for performance events , try the following troubleshooting steps:
Check the setup of the Performance Monitoring Gradle plugin, as follows:
Make sure that you added the plugin correctly. Specifically, check the following:
- You added the plugin (
) in your module (app-level)apply plugin: 'com.google.firebase.firebase-perf' build.gradlefile. - You included the classpath dependency for the plugin (
) in your project-levelclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradlefile.
- You added the plugin (
Make sure that the plugin is not disabled through either of the following flags:
-
instrumentationEnabledin your module (app-level)build.gradlefile -
firebasePerformanceInstrumentationEnabledin yourgradle.propertiesfile
-
Check that the Performance Monitoring SDK is not disabled through either of the following flags in your
AndroidManifest.xmlfile:-
firebase_performance_collection_enabled -
firebase_performance_collection_deactivated
-
Make sure that Performance Monitoring is not disabled at runtime .
If you can't find anything that's disabled in your app, contact Firebase Support .
If you're missing data for screen rendering traces, try the following troubleshooting steps:
Make sure that you're using the latest version of the Android SDK (v22.0.4). Screen rendering traces are only available with v15.2.0 or later.
Make sure that you haven't manually disabled Hardware Acceleration for a screen.
Make sure that you're not using DexGuard or Jack. Performance Monitoring is incompatible with these toolchains.
DexGuard disables automatic collection of app start, app-in-foreground, and app-in-background traces. However, any custom code traces should behave normally if your app uses DexGuard.
Jack is deprecated and generally should not be used in your app.
Are you seeing performance data for automatically collected traces but not for custom code traces ? Try the following troubleshooting steps:
If you instrumented custom code traces via the Trace API , check the setup of the traces, especially the following:
- Names for custom code traces and custom metrics must meet the following requirements: no leading or trailing whitespace, no leading underscore (
_) character, and max length is 32 characters. - All traces must be started and stopped. Any trace that is not started, not stopped, or stopped before started will not be logged.
- Names for custom code traces and custom metrics must meet the following requirements: no leading or trailing whitespace, no leading underscore (
If you instrumented custom code traces via
@AddTracenotation , check the setup of the Performance Monitoring Gradle plugin:Make sure that you added the plugin correctly. Specifically, check the following:
- You added the plugin (
) in your module (app-level)apply plugin: 'com.google.firebase.firebase-perf' build.gradlefile. - You included the classpath dependency for the plugin (
) in your project-levelclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradlefile.
- You added the plugin (
Make sure that the plugin is not disabled through either of the following flags:
-
instrumentationEnabledin your module (app-level)build.gradlefile -
firebasePerformanceInstrumentationEnabledin yourgradle.propertiesfile
-
Check your log messages to make sure that Performance Monitoring is logging expected custom code traces.
If Performance Monitoring is logging events, but no data displays after 24 hours, contact Firebase Support .
If you're missing network request data, try the following troubleshooting steps:
For Android apps, the Performance Monitoring Gradle plugin enables instrumentation that provides automatic monitoring of HTTP/S network requests . Check the following:
Make sure that you added the plugin correctly. Specifically, check the following:
- You added the plugin (
) in your module (app-level)apply plugin: 'com.google.firebase.firebase-perf' build.gradlefile. - You included the classpath dependency for the plugin (
) in your project-levelclasspath 'com.google.firebase:perf-plugin:2.0.2' build.gradlefile.
- You added the plugin (
Make sure that the plugin is not disabled through either of the following flags:
-
instrumentationEnabledin your module (app-level)build.gradlefile -
firebasePerformanceInstrumentationEnabledin yourgradle.propertiesfile
-
Check for network library incompatibility. Performance Monitoring automatically collects metrics for network requests that use the following networking libraries: OkHttp 3.xx, Java's URLConnection, and Apache HttpClient.
Note that you can add custom monitoring for network requests .
Be aware of the following:
Depending on the behavior of your code and networking libraries used by your code, Performance Monitoring might only report on network requests that are completed. This means that HTTP/S connections that are left open might not be reported.
Performance Monitoring is not compatible with DexGuard and Jack.
- DexGuard disables monitoring of HTTP/S network requests.
- Jack is deprecated and generally should not be used in your app.
Performance Monitoring does not report on network requests with invalid
Content-Typeheaders. However, network requests without theContent-Typeheaders will still be accepted.
Learn more about how Performance Monitoring aggregates network request data under URL patterns.
You can also try out custom URL patterns !
سوالات متداول
We replaced Top Issues with Recent Alerts as a follow-up to our recent introduction of alerts, which automatically notify you when the thresholds you set are crossed. Issues are now deprecated and replaced by alerts.
The apps selector at the top of the Performance card filters the alert entries under Recent Alerts . Only the three most recent alerts for the app(s) selected are displayed.
To learn more about alerts, see Set up alerts for performance issues .
Performance Monitoring supports alerts for metrics that exceed defined thresholds. To avoid confusion with these configurable thresholds for performance metrics, we removed the ability to configure thresholds for issues .
We replaced the Details and Metrics pages with a newly redesigned, centralized user interface (UI) to improve how you troubleshoot issues. This new troubleshooting UI offers the same core functionality that Details and Metrics offered. To learn more about troubleshooting, see View more data for a specific trace .
Performance Monitoring collects performance data from your app's user devices. If your application has many users or if the app generates a large amount of performance activity, Performance Monitoring might limit data collection to a subset of devices to reduce the number of processed events. These limits are high enough so that, even with fewer events, the metric values are still representative of your user's app experience.
To manage the volume of data that we collect, Performance Monitoring uses the following sampling options:
On-device rate limiting : To prevent a device from sending sudden bursts of traces, we limit the number of code and network request traces sent from a device to 300 events every 10 mins. This approach protects the device from looped instrumentations that can send large amounts of performance data, and it prevents a single device from skewing the performance measurements.
Dynamic sampling : Performance Monitoring collects a limited number of code traces and network request traces per app daily across all app users. A dynamic sampling rate is fetched on devices (using Firebase Remote Config ) to determine whether a random device should capture and send traces. A device that is not selected for sampling does not send any events. The dynamic sampling rate is app-specific and adjusts to ensure that the overall volume of collected data remains below the limit.
Projects that enabled BigQuery integration receive a higher limit for the number of network request traces.
User sessions send additional, detailed data from a user's device, requiring more resources to capture and send the data. To minimize the impact of user sessions, Performance Monitoring might also restrict the number of sessions.
Server-side rate limiting : To ensure that apps don't exceed the sampling limit, Performance Monitoring might use server-side sampling to drop some events received from devices. Although this type of limiting doesn't change the effectiveness of our metrics, it may cause minor pattern shifts, including the following:
- The number of traces can differ from the number of times that a piece of code was executed.
- Traces that are closely coupled in code may each have a different number of samples.
We replaced the Issues tab with the introduction of Alerts, which automatically notifies you when the thresholds you set are exceeded. You no longer need to manually check the Firebase console to determine the status of a threshold. To learn about Alerts, see Set up alerts for performance issues .
We've redesigned the Performance Monitoring section of the Firebase console so that the Dashboard tab displays your key metrics and all your traces in one space. As part of the redesign, we removed the On device and Network pages.
The traces table at the bottom of the Dashboard tab has all the same information that the On device and Network tabs displayed, but with some added features, including the ability to sort your traces by the percentage change for a specific metric. To view all the metrics and data for a specific trace, click the trace name in the traces table.
View your traces in the following subtabs of the traces table:
- Network request traces (both out-of-the-box and custom) — Network requests subtab
- Custom code traces — Custom traces subtab
- App start, app-in-foreground, app-in-background traces — Custom traces subtab
- Screen rendering traces — Screen rendering subtab
- Page load traces — Page load subtab
For details about the traces table and viewing metrics and data, visit the console overview page ( iOS+ | Android | Web ).
Slow rendering frames and frozen frames are calculated with an assumed device refresh rate of 60Hz. If a device refresh rate is lower than 60Hz, each frame will have a slower rendering time because fewer frames are rendered per second. Slower rendering times can cause more slow or frozen frames to be reported because more frames will be rendered slower or will freeze. However, if a device refresh rate is higher than 60Hz, each frame will have a faster rendering time. This can cause fewer slow or frozen frames to be reported. This is a current limitation in the Performance Monitoring SDK.
To see the performance of fragments in addition to app activity, make sure that your app is using Performance Monitoring Android SDK version 20.1.0 or above. To learn more, see Add Performance Monitoring to your app .
Each of the fragment and activity traces is based on its class name as defined in your application. Each of the screen traces contains the st prefix followed by the name of the class. On the Firebase console, the prefix is removed. To learn more, see Learn about screen rendering performance data (Apple & Android apps) .
Performance Monitoring conducts event sampling across all events collected on a device. This approach lets us collect the minimum events needed from user devices to provide performance metrics.
Performance Monitoring lets you set up alerts for the metrics you care about. For generated screen rendering traces, you can set up alerts to notify you when the slow and frozen frames percentage exceeds a threshold that you set.
Performance Monitoring for Android uses bytecode instrumentation to provide some out-of-the-box features like monitoring HTTP/S network requests . As a part of compilation, the process requires iteration through all the classes of your app (including dependencies) to instrument the code that is crucial in measuring the network request performance of your application.
Here are some key contributors to an increase in build time:
- Number of classes or files
- Size of each of those classes (lines of code)
- Your machine configuration
- Initial build versus a subsequent build (subsequent builds are usually faster than the initial build)
To optimize your build time, consider modularizing your code .
Starting with v1.3.3 of the Performance Monitoring plugin, we've concentrated on making considerable improvements in the incremental build processing and caching of library inputs. To receive the most recent build time improvements, make sure to use the latest version of the plugin (v2.0.2) .
Note that you can disable the Performance Monitoring plugin for your debug builds locally if you want to avoid long build times. However, this approach is not recommended for production builds, as it could result in missed performance measurements for the network requests in your app.
Performance Monitoring for Android uses bytecode instrumentation to provide some out-of-the-box features like monitoring HTTP/S network requests . As a part of compilation, the process requires iteration through all the classes of your app (including dependencies) to instrument the code that is crucial in measuring the network request performance of your application.
If you get build errors like JSR/RET are not supported with computeFrames option or similar errors after integrating with the Performance Monitoring plugin, this might be because you also have a dependency on a library that's incompatible with the Performance Monitoring Gradle plugin.
To get around this, you can exclude incompatible classes/libraries from being instrumented by following these steps:
- Update to the latest version of Performance Monitoring Gradle plugin (minimum v1.4.0 ).
- Update your Android Gradle plugin version to v7.2.0 or newer.
- Add the following flag to your module (app-level)
build.gradlefile to exclude the incompatible classes/libraries from being instrumented: To learn more about theandroid { // ... androidComponents { onVariants(selector().all(), { instrumentation.excludes.add("example.incompatible.library") }) } }
excludeproperty of Android Gradle plugin'sInstrumentationAPI, see Instrumentation .
Please file a Github issue when you encounter build errors due to incompatible libraries so that they can also be excluded from being instrumented in the Performance Monitoring plugin.
If you have enabled the BigQuery integration for Firebase Performance Monitoring , your data will be exported to BigQuery 12 to 24 hours after the end of the day (Pacific Time).
For example, the data for April 19th will be available in BigQuery on April 20th between 12:00pm and midnight (all dates and times are Pacific Time).
Near real-time data processing and display
Firebase Performance Monitoring processes collected performance data as it comes in, which results in near real-time data display in the Firebase console. Processed data displays in the console within a few minutes of its collection, hence the term "near real-time".
To take advantage of near real-time data processing, make sure your app uses a real-time compatible SDK version .
To take advantage of near real-time data processing, you only need to make sure that your app uses a Performance Monitoring SDK version that's compatible with real-time data processing.
These are the real-time compatible SDK versions:
- iOS — v7.3.0 or later
- tvOS — v8.9.0 or later
- Android — v19.0.10 or later (or Firebase Android BoM v26.1.0 or later)
- Web — v7.14.0 or later
Note that we always recommend using the latest version of SDK, but any version listed above will enable Performance Monitoring to process your data in near real time.
These are the SDK versions compatible with real-time data processing:
- iOS — v7.3.0 or later
- tvOS — v8.9.0 or later
- Android — v19.0.10 or later (or Firebase Android BoM v26.1.0 or later)
- Web — v7.14.0 or later
Note that we always recommend using the latest version of SDK, but any version listed above will enable Performance Monitoring to process your data in near real time.
If your app doesn't use a real-time compatible SDK version, you will still see all your app's performance data in the Firebase console. However, the display of performance data will be delayed by roughly 36 hours from the time of its collection.
Yes! Regardless of which SDK version an app instance uses, you'll see performance data from all your users.
However, if you're looking at recent data (less than roughly 36 hours old), then the displayed data is from users of app instances using a real-time compatible SDK version. The non-recent data, though, includes performance data from all versions of your app.
Contacting Firebase Support
If you reach out to Firebase Support , always include your Firebase App ID. Find your Firebase App ID in the Your apps card of your Project settings .