Bug 1498160 - Define new snapshot APIs for scalars and histograms r=chutten
authorJan-Erik Rediger <jrediger@mozilla.com>
Thu, 18 Oct 2018 12:09:19 +0000
changeset 441896 a5849dab9066759af0c542aa608cad47fe8bc1c6
parent 441895 f2d7d033c14fe7a9e94c6c5ddec4e5dcf165be7c
child 441897 5c84e7821c57ada673b4cf554a000961f57efdf8
push id34878
push useraciure@mozilla.com
push dateThu, 18 Oct 2018 16:35:36 +0000
treeherdermozilla-central@5be96992e33c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1498160
milestone64.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 1498160 - Define new snapshot APIs for scalars and histograms r=chutten For now this defers to the existing APIs and determines the correct dataset from a global flag. Differential Revision: https://phabricator.services.mozilla.com/D8858
toolkit/components/telemetry/core/Telemetry.cpp
toolkit/components/telemetry/core/nsITelemetry.idl
--- a/toolkit/components/telemetry/core/Telemetry.cpp
+++ b/toolkit/components/telemetry/core/Telemetry.cpp
@@ -613,16 +613,60 @@ TelemetryImpl::AddSQLInfo(JSContext *cx,
 
 NS_IMETHODIMP
 TelemetryImpl::SetHistogramRecordingEnabled(const nsACString &id, bool aEnabled)
 {
   return TelemetryHistogram::SetHistogramRecordingEnabled(id, aEnabled);
 }
 
 NS_IMETHODIMP
+TelemetryImpl::GetSnapshotForHistograms(const nsACString& aStoreName,
+                                        bool aClearStore, JSContext* aCx,
+                                        JS::MutableHandleValue aResult)
+{
+  unsigned int dataset = mCanRecordExtended ?
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN :
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTOUT;
+  return TelemetryHistogram::CreateHistogramSnapshots(aCx, aResult, dataset, aClearStore);
+}
+
+NS_IMETHODIMP
+TelemetryImpl::GetSnapshotForKeyedHistograms(const nsACString& aStoreName,
+                                             bool aClearStore, JSContext* aCx,
+                                             JS::MutableHandleValue aResult)
+{
+  unsigned int dataset = mCanRecordExtended ?
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN :
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTOUT;
+  return TelemetryHistogram::GetKeyedHistogramSnapshots(aCx, aResult, dataset, aClearStore);
+}
+
+NS_IMETHODIMP
+TelemetryImpl::GetSnapshotForScalars(const nsACString& aStoreName,
+                                     bool aClearStore, JSContext* aCx,
+                                     JS::MutableHandleValue aResult)
+{
+  unsigned int dataset = mCanRecordExtended ?
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN :
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTOUT;
+  return TelemetryScalar::CreateSnapshots(dataset, aClearStore, aCx, 1, aResult);
+}
+
+NS_IMETHODIMP
+TelemetryImpl::GetSnapshotForKeyedScalars(const nsACString& aStoreName,
+                                          bool aClearStore, JSContext* aCx,
+                                          JS::MutableHandleValue aResult)
+{
+  unsigned int dataset = mCanRecordExtended ?
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTIN :
+    nsITelemetry::DATASET_RELEASE_CHANNEL_OPTOUT;
+  return TelemetryScalar::CreateKeyedSnapshots(dataset, aClearStore, aCx, 1, aResult);
+}
+
+NS_IMETHODIMP
 TelemetryImpl::SnapshotHistograms(unsigned int aDataset,
                                   bool aClearHistograms, JSContext* aCx,
                                   JS::MutableHandleValue aResult)
 {
   return TelemetryHistogram::CreateHistogramSnapshots(aCx, aResult, aDataset,
                                                       aClearHistograms);
 }
 
--- a/toolkit/components/telemetry/core/nsITelemetry.idl
+++ b/toolkit/components/telemetry/core/nsITelemetry.idl
@@ -47,16 +47,70 @@ interface nsITelemetry : nsISupports
    * DATASET_RELEASE_CHANNEL_OPTIN - the extended dataset that is opt-in on release,
    *                                 opt-out on pre-release channels.
    */
   const unsigned long DATASET_RELEASE_CHANNEL_OPTOUT = 0;
   const unsigned long DATASET_RELEASE_CHANNEL_OPTIN = 1;
 
 
   /**
+   * Serializes the histograms from the given store to a JSON-style object.
+   * The returned structure looks like:
+   *   { "process": { "name1": histogramData1, "name2": histogramData2 }, ... }
+   *
+   * Where histogramDataN has the following properties:
+   *   min - minimum bucket size
+   *   max - maximum bucket size
+   *   histogram_type - HISTOGRAM_EXPONENTIAL, HISTOGRAM_LINEAR, HISTOGRAM_BOOLEAN,
+   *                    HISTOGRAM_FLAG, HISTOGRAM_COUNT, or HISTOGRAM_CATEGORICAL
+   *   counts - array representing contents of the buckets in the histogram
+   *   ranges - array with calculated bucket sizes
+   *   sum - sum of the bucket contents
+   * TODO(bug 1468761): Return packed histograms.
+   *
+   * @param aStoreName The name of the store to snapshot. Ignored at the moment.
+   * @param aClearStore Whether to clear out the histograms in the named store after snapshotting.
+   */
+  [implicit_jscontext]
+  jsval getSnapshotForHistograms(in ACString aStoreName, in boolean aClearStore);
+
+  /**
+   * Serializes the keyed histograms from the given store to a JSON-style object.
+   * The returned structure looks like:
+   *   { "process": { "name1": { "key_1": histogramData1, "key_2": histogramData2 }, ...}, ... }
+   *
+   * @param aStoreName The name of the store to snapshot. Ignored at the moment.
+   * @param aClearStore Whether to clear out the keyed histograms in the named store after snapshotting.
+   */
+  [implicit_jscontext]
+  jsval getSnapshotForKeyedHistograms(in ACString aStoreName, in boolean aClearStore);
+
+  /**
+   * Serializes the scalars from the given store to a JSON-style object.
+   * The returned structure looks like:
+   *   { "process": { "category1.probe": 1,"category1.other_probe": false, ... }, ... }.
+   *
+   * @param aStoreName The name of the store to snapshot. Ignored at the moment.
+   * @param aClearStore Whether to clear out the scalars in the named store after snapshotting.
+   */
+  [implicit_jscontext]
+  jsval getSnapshotForScalars(in ACString aStoreName, in boolean aClearStore);
+
+  /**
+   * Serializes the keyed scalars from the given store to a JSON-style object.
+   * The returned structure looks like:
+   *   { "process": { "category1.probe": { "key_1": 2, "key_2": 1, ... }, ... }, ... }
+   *
+   * @param aStoreName The name of the store to snapshot. Ignored at the moment.
+   * @param aClearStore Whether to clear out the keyed scalars in the named store after snapshotting.
+   */
+  [implicit_jscontext]
+  jsval getSnapshotForKeyedScalars(in ACString aStoreName, in boolean aClearStore);
+
+  /**
    * Serializes the histograms from the given dataset to a JSON-style object.
    * The returned structure looks like:
    *   { process1: {name1: {histogramData1}, name2:{histogramData2}...}}
    *
    * Where histogramDataN has the following properties:
    *   min - minimum bucket size
    *   max - maximum bucket size
    *   histogram_type - HISTOGRAM_EXPONENTIAL, HISTOGRAM_LINEAR, HISTOGRAM_BOOLEAN,