ফায়ারবেস পারফরম্যান্স মনিটরিং অক্ষম করুন


অ্যাপ তৈরি ও পরীক্ষার সময় Performance Monitoring নিষ্ক্রিয় করে রাখলে তা আপনার জন্য সহায়ক হতে পারে।

উদাহরণস্বরূপ, আপনার অ্যাপ বিল্ড প্রক্রিয়ার সময় Performance Monitoring নিষ্ক্রিয় করার মাধ্যমে, আপনি যা করতে পারেন:

  • Disable certain functionalities of Performance Monitoring (such as those provided by the Performance Monitoring Gradle plugin ) in your debug builds, but re-enable the functionalities for your release build.

  • আপনার অ্যাপ বিল্ড করার সময় Performance Monitoring নিষ্ক্রিয় করুন, কিন্তু রানটাইমে আপনার অ্যাপকে এটি পুনরায় সক্রিয় করার অনুমতি দিন।

  • আপনার অ্যাপ বিল্ড করার সময় Performance Monitoring নিষ্ক্রিয় করুন, এবং রানটাইমে আপনার অ্যাপকে এটি পুনরায় সক্রিয় করার অনুমতি দেবেন না।

You can also build your app with Performance Monitoring enabled , but use Firebase Remote Config to give you flexibility to disable (and re-enable) Performance Monitoring in your production app. With this option, you can even configure your app to let users opt-in or opt-out of using Performance Monitoring .

আপনার অ্যাপ বিল্ড প্রক্রিয়া চলাকালীন Performance Monitoring নিষ্ক্রিয় করুন।

আপনার বিল্ড প্রক্রিয়ার সময় Performance Monitoring গ্রেডল প্লাগইন এবং/অথবা Performance Monitoring অ্যান্ড্রয়েড লাইব্রেরি নিষ্ক্রিয় করার মাধ্যমে আপনি Performance Monitoring বন্ধ করতে পারেন।

During development and debugging, disabling the plugin is useful because instrumentation by the plugin can contribute to increased build time. You might, though, consider keeping the library enabled so that you can still view performance data from app start, app-in-foreground, and app-in-background traces as well as any custom code traces in your app.

Performance Monitoring গ্রেডল প্লাগইন নিষ্ক্রিয় করুন

নিম্নলিখিত অপশনগুলো ব্যবহার করে একটি instrumentationEnabled ফ্ল্যাগ যোগ করার মাধ্যমে আপনি Performance Monitoring প্লাগইনটি নিষ্ক্রিয় করতে পারেন:

  • এক্সটেনশন প্রপার্টি — কম্পাইল করার সময় একটি নির্দিষ্ট বিল্ড ভ্যারিয়েন্টের জন্য প্লাগইনটি নিষ্ক্রিয় করে।

  • প্রজেক্ট প্রপার্টি — কম্পাইল করার সময় সকল বিল্ড ভ্যারিয়েন্টের জন্য প্লাগইনটি নিষ্ক্রিয় করে দেয়।

একটি এক্সটেনশন প্রপার্টি ফ্ল্যাগের মাধ্যমে প্লাগইনটি নিষ্ক্রিয় করুন।

এক্সটেনশনস প্রপার্টি ফ্ল্যাগ ব্যবহার করে, আপনি কম্পাইল করার সময় একটি নির্দিষ্ট বিল্ড ভ্যারিয়েন্টের জন্য Performance Monitoring প্লাগইনটি নিষ্ক্রিয় করতে পারেন।

  1. আপনার রুট-লেভেলের (প্রজেক্ট-লেভেলের) Gradle ফাইলে ( <project>/build.gradle.kts অথবা <project>/build.gradle ), নিশ্চিত করুন যে আপনার Android Gradle Plugin ডিপেন্ডেন্সিটি v3.4.0 বা তার পরবর্তী সংস্করণ হিসেবে নির্দিষ্ট করা আছে।

    অ্যান্ড্রয়েড গ্রেডল প্লাগইনের আগের সংস্করণগুলোর ক্ষেত্রে, আপনি এখনও একটি নির্দিষ্ট বিল্ড ভ্যারিয়েন্টের জন্য Performance Monitoring প্লাগইনটি নিষ্ক্রিয় করতে পারেন, কিন্তু সেই ভ্যারিয়েন্টের জন্য বিল্ড-টাইম অবদান সম্পূর্ণরূপে বিলুপ্ত হবে না।

  2. Performance Monitoring প্লাগইনটি নিষ্ক্রিয় করতে, আপনার মডিউল (অ্যাপ-লেভেল) গ্রেডল ফাইলে (সাধারণত <project>/<app-module>/build.gradle.kts অথবা <project>/<app-module>/build.gradle ) নিম্নলিখিত ফ্ল্যাগটি যোগ করুন এবং তারপর এটিকে false এ সেট করুন।

    Kotlin

    import com.google.firebase.perf.plugin.FirebasePerfExtension
    
    // ...
    
    android {
      // ...
      buildTypes {
        getByName("debug") {
          configure<FirebasePerfExtension> {
            // Set this flag to 'false' to disable @AddTrace annotation processing and
            // automatic monitoring of HTTP/S network requests
            // for a specific build variant at compile time.
            setInstrumentationEnabled(false)
          }
        }
      }
    }

    Groovy

    android {
      // ...
      buildTypes {
        debug {
          FirebasePerformance {
            // Set this flag to 'false' to disable @AddTrace annotation processing and
            // automatic monitoring of HTTP/S network requests
            // for a specific build variant at compile time.
            instrumentationEnabled false
          }
        }
      }
    }

প্রজেক্ট প্রপার্টি ফ্ল্যাগের মাধ্যমে প্লাগইনটি নিষ্ক্রিয় করুন।

প্রজেক্ট প্রপার্টি ফ্ল্যাগ ব্যবহার করে, আপনি কম্পাইল করার সময় সমস্ত বিল্ড ভ্যারিয়েন্টের জন্য Performance Monitoring প্লাগইনটি নিষ্ক্রিয় করতে পারেন।

Performance Monitoring প্লাগইনটি নিষ্ক্রিয় করতে, আপনার gradle.properties ফাইলে নিম্নলিখিত ফ্ল্যাগটি যোগ করুন এবং এটিকে false এ সেট করুন।

// ...

// Set this flag to 'false' to disable @AddTrace annotation processing and
// automatic monitoring of HTTP/S network requests
// for all build variants at compile time.
firebasePerformanceInstrumentationEnabled=false

Performance Monitoring অ্যান্ড্রয়েড লাইব্রেরি নিষ্ক্রিয় করুন

যদি আপনি কম্পাইল করার সময় Performance Monitoring লাইব্রেরিটি নিষ্ক্রিয় করে দেন, তাহলে আপনার অ্যাপ রানটাইমে লাইব্রেরিটি সক্রিয় করতে পারবে কিনা, তা আপনি বেছে নিতে পারেন।

কম্পাইল করার সময় লাইব্রেরিটি নিষ্ক্রিয় করুন, কিন্তু আপনার অ্যাপকে রানটাইমে এটি সক্রিয় করার অনুমতি দিন।

আপনার অ্যাপের AndroidManifest.xml ফাইলে নিম্নলিখিত <meta-data> এলিমেন্টটি যোগ করুন:

  <application>
    <meta-data
      android:name="firebase_performance_collection_enabled"
      android:value="false" />
  </application>

কম্পাইল করার সময় লাইব্রেরিটি নিষ্ক্রিয় করুন, কিন্তু আপনার অ্যাপকে রানটাইমে এটি সক্রিয় করার অনুমতি দেবেন না।

আপনার অ্যাপের AndroidManifest.xml ফাইলে নিম্নলিখিত <meta-data> এলিমেন্টটি যোগ করুন:

  <application>
    <meta-data
      android:name="firebase_performance_collection_deactivated"
      android:value="true" />
  </application>

Remote Config ব্যবহার করে রানটাইমে আপনার অ্যাপ নিষ্ক্রিয় করুন।

Firebase Remote Config আপনাকে আপনার অ্যাপের আচরণ এবং চেহারায় পরিবর্তন আনার সুযোগ দেয়, তাই এটি আপনার অ্যাপের ডেপ্লয় করা ইনস্ট্যান্সগুলোতে Performance Monitoring নিষ্ক্রিয় করার একটি আদর্শ উপায়।

পরবর্তী বার আপনার অ্যান্ড্রয়েড অ্যাপ চালু হওয়ার সময় Performance Monitoring ডেটা সংগ্রহ নিষ্ক্রিয় করতে, নিচে দেখানো উদাহরণ কোডটি ব্যবহার করুন। অ্যান্ড্রয়েড অ্যাপে Remote Config ব্যবহার সম্পর্কে আরও তথ্যের জন্য, অ্যান্ড্রয়েডে Firebase Remote Config ব্যবহার দেখুন।

  1. নিশ্চিত করুন যে Remote Config আপনার মডিউল (অ্যাপ-লেভেল) গ্রেডল ফাইলের (সাধারণত <project>/<app-module>/build.gradle.kts অথবা <project>/<app-module>/build.gradle ) dependencies সেকশনে আছে:

    Kotlin

      implementation("com.google.firebase:firebase-config-ktx:23.1.0")
    

    Java

      implementation("com.google.firebase:firebase-config:23.1.0")
    
  2. Remote Config সেট আপ করুন এবং যদি perf_disable true সেট করা থাকে, তাহলে Performance Monitoring নিষ্ক্রিয় করুন:

    Kotlin

    // Setup remote config
    val config = Firebase.remoteConfig
    
    // You can uncomment the following two statements to permit more fetches when
    // validating your app, but you should comment out or delete these lines before
    // distributing your app in production.
    // val configSettings = remoteConfigSettings {
    //     minimumFetchIntervalInSeconds = 3600
    // }
    // config.setConfigSettingsAsync(configSettings)
    // Load in-app defaults from an XML file that sets perf_disable to false until you update
    // values in the Firebase Console
    
    // Observe the remote config parameter "perf_disable" and disable Performance Monitoring if true
    config.setDefaultsAsync(R.xml.remote_config_defaults)
        .addOnCompleteListener { task ->
            if (task.isSuccessful) {
                Firebase.performance.isPerformanceCollectionEnabled = !config.getBoolean("perf_disable")
            } else {
                // An error occurred while setting default parameters
            }
        }

    Java

    // Setup remote config
    final FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
    
    // You can uncomment the following two statements to permit more fetches when
    // validating your app, but you should comment out or delete these lines before
    // distributing your app in production.
    // FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
    //       .setMinimumFetchIntervalInSeconds(3600)
    //       .build();
    // config.setConfigSettingsAsync(configSettings);
    // Load in-app defaults from an XML file that sets perf_disable to false until you update
    // values in the Firebase Console
    
    //Observe the remote config parameter "perf_disable" and disable Performance Monitoring if true
    config.setDefaultsAsync(R.xml.remote_config_defaults)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        if (config.getBoolean("perf_disable")) {
                            FirebasePerformance.getInstance().setPerformanceCollectionEnabled(false);
                        } else {
                            FirebasePerformance.getInstance().setPerformanceCollectionEnabled(true);
                        }
                    } else {
                        // An error occurred while setting default parameters
                    }
                }
            });
  3. Remote Config মানগুলি ফেচ ও অ্যাক্টিভেট করতে MainActivity.java তে নিম্নলিখিত কোডটি যোগ করুন:

    Kotlin

    // Remote Config fetches and activates parameter values from the service
    val config = Firebase.remoteConfig
    config.fetch(3600)
        .continueWithTask { task ->
            if (!task.isSuccessful) {
                task.exception?.let {
                    throw it
                }
            }
            config.activate()
        }
        .addOnCompleteListener(this) { task ->
            if (task.isSuccessful) {
                // Parameter values successfully activated
                // ...
            } else {
                // Handle errors
            }
        }

    Java

    //Remote Config fetches and activates parameter values from the service
    final FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
    config.fetch(3600)
            .continueWithTask(new Continuation<Void, Task<Boolean>>() {
                @Override
                public Task<Boolean> then(@NonNull Task<Void> task) throws Exception {
                    if (!task.isSuccessful()) {
                        throw task.getException();
                    }
                    return config.activate();
                }
            })
            .addOnCompleteListener(new OnCompleteListener<Boolean>() {
                @Override
                public void onComplete(@NonNull Task<Boolean> task) {
                    if (task.isSuccessful()) {
                        // Parameter values successfully activated
                        // ...
                    } else {
                        // Handle errors
                    }
                }
            });
  4. Firebase কনসোলে Performance Monitoring নিষ্ক্রিয় করতে, আপনার অ্যাপের প্রজেক্টে একটি `perf_disable` প্যারামিটার তৈরি করুন এবং এর মান ` true সেট করুন।

    এই পরিবর্তনটি Performance Monitoring SDK-এর কলগুলোকে "নো অপারেশন" কলে (NOOPs) পরিণত করবে, যার ফলে আপনার অ্যাপে Performance Monitoring SDK ব্যবহারের কারণে অ্যাপের পারফরম্যান্সের উপর কোনো উল্লেখযোগ্য প্রভাব পড়বে না।

    আপনি যদি perf_disable- এর মান false সেট করেন, তাহলেও Performance Monitoring সক্রিয় থাকবে।