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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan-Erik Rediger 2018-10-18 12:09:19 +00:00
Родитель 41b3968ced
Коммит ee01d1cc02
2 изменённых файлов: 98 добавлений и 0 удалений

Просмотреть файл

@ -617,6 +617,50 @@ 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,

Просмотреть файл

@ -51,6 +51,60 @@ interface nsITelemetry : nsISupports
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: