bug 1410907 - Add CanRecord(Pre)Release data to nsITTelemetry r=Dexter
authorChris H-C <chutten@mozilla.com>
Fri, 03 Nov 2017 12:44:23 -0400
changeset 443826 eba518f10477b43db1677bbc6ef591309e427fed
parent 443825 ea8ee7aee5b896c78de6fe8e500dcb0f93c273bc
child 443827 f4e2e8992d066900c8bcd4d76a39a45369a2c20a
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter
bugs1410907
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1410907 - Add CanRecord(Pre)Release data to nsITTelemetry r=Dexter We're starting a shift towards talking about release/prerelease data instead of base/extended collection. For now this is just a naming change. At the same time, we can render these attributes read-only, which is nice. MozReview-Commit-ID: IRuKpzLYW7i
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/Telemetry.h
toolkit/components/telemetry/nsITelemetry.idl
toolkit/components/telemetry/tests/unit/test_TelemetryController.js
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -157,16 +157,18 @@ public:
     struct Stat otherThreads;
   };
   typedef nsBaseHashtableET<nsCStringHashKey, StmtStats> SlowSQLEntryType;
 
   static void RecordIceCandidates(const uint32_t iceCandidateBitmask,
                                   const bool success);
   static bool CanRecordBase();
   static bool CanRecordExtended();
+  static bool CanRecordReleaseData();
+  static bool CanRecordPrereleaseData();
 private:
   TelemetryImpl();
   ~TelemetryImpl();
 
   static nsCString SanitizeSQL(const nsACString& sql);
 
   enum SanitizedState { Sanitized, Unsanitized };
 
@@ -1169,16 +1171,27 @@ TelemetryImpl::SetCanRecordExtended(bool
     TelemetryHistogram::SetCanRecordExtended(canRecord);
     TelemetryScalar::SetCanRecordExtended(canRecord);
     TelemetryEvent::SetCanRecordExtended(canRecord);
     mCanRecordExtended = canRecord;
   }
   return NS_OK;
 }
 
+NS_IMETHODIMP
+TelemetryImpl::GetCanRecordReleaseData(bool* ret) {
+  *ret = mCanRecordBase;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+TelemetryImpl::GetCanRecordPrereleaseData(bool* ret) {
+  *ret = mCanRecordExtended;
+  return NS_OK;
+}
 
 NS_IMETHODIMP
 TelemetryImpl::GetIsOfficialTelemetry(bool *ret) {
 #if defined(MOZILLA_OFFICIAL) && defined(MOZ_TELEMETRY_REPORTING) && !defined(DEBUG)
   *ret = true;
 #else
   *ret = false;
 #endif
@@ -1563,16 +1576,28 @@ TelemetryImpl::CanRecordExtended()
   if (!sTelemetry) {
     return false;
   }
   bool canRecordExtended;
   nsresult rv = sTelemetry->GetCanRecordExtended(&canRecordExtended);
   return NS_SUCCEEDED(rv) && canRecordExtended;
 }
 
+bool
+TelemetryImpl::CanRecordReleaseData()
+{
+  return CanRecordBase();
+}
+
+bool
+TelemetryImpl::CanRecordPrereleaseData()
+{
+  return CanRecordExtended();
+}
+
 NS_IMPL_ISUPPORTS(TelemetryImpl, nsITelemetry, nsIMemoryReporter)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITelemetry, TelemetryImpl::CreateTelemetryInstance)
 
 #define NS_TELEMETRY_CID \
   {0xaea477f2, 0xb3a2, 0x469c, {0xaa, 0x29, 0x0a, 0x82, 0xd1, 0x32, 0xb8, 0x29}}
 NS_DEFINE_NAMED_CID(NS_TELEMETRY_CID);
 
 const Module::CIDEntry kTelemetryCIDs[] = {
@@ -1949,16 +1974,28 @@ CanRecordBase()
 }
 
 bool
 CanRecordExtended()
 {
   return TelemetryImpl::CanRecordExtended();
 }
 
+bool
+CanRecordReleaseData()
+{
+  return TelemetryImpl::CanRecordReleaseData();
+}
+
+bool
+CanRecordPrereleaseData()
+{
+  return TelemetryImpl::CanRecordPrereleaseData();
+}
+
 void
 RecordSlowSQLStatement(const nsACString &statement,
                        const nsACString &dbName,
                        uint32_t delay)
 {
   TelemetryImpl::RecordSlowStatement(statement, dbName, delay);
 }
 
--- a/toolkit/components/telemetry/Telemetry.h
+++ b/toolkit/components/telemetry/Telemetry.h
@@ -254,16 +254,31 @@ bool CanRecordBase();
 
 /**
  * Indicates whether Telemetry extended data recording is turned on.  This is intended
  * to guard calls to Accumulate when the statistic being recorded is expensive to compute.
  */
 bool CanRecordExtended();
 
 /**
+ * Indicates whether Telemetry release data recording is turned on. Usually true.
+ *
+ * @see nsITelemetry.canRecordReleaseData
+ */
+bool CanRecordReleaseData();
+
+/**
+ * Indicates whether Telemetry pre-release data recording is turned on. Tends
+ * to be true on pre-release channels.
+ *
+ * @see nsITelemetry.canRecordPrereleaseData
+ */
+bool CanRecordPrereleaseData();
+
+/**
  * Records slow SQL statements for Telemetry reporting.
  *
  * @param statement - offending SQL statement to record
  * @param dbName - DB filename
  * @param delay - execution time in milliseconds
  */
 void RecordSlowSQLStatement(const nsACString &statement,
                             const nsACString &dbName,
--- a/toolkit/components/telemetry/nsITelemetry.idl
+++ b/toolkit/components/telemetry/nsITelemetry.idl
@@ -270,16 +270,44 @@ interface nsITelemetry : nsISupports
    * user has explicitly opted out of Telemetry on Nightly/Aurora/Beta or if manually
    * set to false during tests.
    *
    * Set this to false in tests to disable gathering of extended telemetry statistics.
    */
   attribute boolean canRecordExtended;
 
   /**
+   * A flag indicating whether Telemetry is recording release data, which is a
+   * smallish subset of our usage data that we're prepared to handle from our
+   * largish release population.
+   *
+   * This is true most of the time.
+   *
+   * This does not indicate whether Telemetry will send any data. That is
+   * governed by user preference and other mechanisms.
+   *
+   * You may use this to determine if it's okay to record your data.
+   */
+  readonly attribute boolean canRecordReleaseData;
+
+  /**
+   * A flag indicating whether Telemetry is recording prerelease data, which is
+   * a largish amount of usage data that we're prepared to handle from our
+   * smallish pre-release population.
+   *
+   * This is true on pre-release branches of Firefox.
+   *
+   * This does not indicate whether Telemetry will send any data. That is
+   * governed by user preference and other mechanisms.
+   *
+   * You may use this to determine if it's okay to record your data.
+   */
+  readonly attribute boolean canRecordPrereleaseData;
+
+  /**
    * A flag indicating whether Telemetry can submit official results (for base or extended
    * data). This is true on official, non-debug builds with built in support for Mozilla
    * Telemetry reporting.
    */
   readonly attribute boolean isOfficialTelemetry;
 
   /**
    * Enable/disable recording for this histogram at runtime.
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
@@ -594,11 +594,18 @@ add_task(async function test_sendNewProf
 add_task(async function test_pingRejection() {
   await TelemetryController.testReset();
   await TelemetryController.testShutdown();
   await sendPing(false, false)
     .then(() => Assert.ok(false, "Pings submitted after shutdown must be rejected."),
           () => Assert.ok(true, "Ping submitted after shutdown correctly rejected."));
 });
 
+add_task(async function test_newCanRecordsMatchTheOld() {
+  Assert.equal(Telemetry.canRecordBase, Telemetry.canRecordReleaseData,
+               "Release Data is the new way to say Base Collection");
+  Assert.equal(Telemetry.canRecordExtended, Telemetry.canRecordPrereleaseData,
+               "Prerelease Data is the new way to say Extended Collection");
+});
+
 add_task(async function stopServer() {
   await PingServer.stop();
 });