Bug 1302663 - Part 2 - Implement Event Telemetry recording. r=froydnj,dexter
This implements the API, storage and serialization for Telemetry event recording.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "TelemetryCommon.h"
|
||||
#include "TelemetryHistogram.h"
|
||||
#include "TelemetryScalar.h"
|
||||
#include "TelemetryEvent.h"
|
||||
#include "WebrtcTelemetry.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
@@ -1862,6 +1863,7 @@ NS_IMETHODIMP
|
||||
TelemetryImpl::SetCanRecordBase(bool canRecord) {
|
||||
TelemetryHistogram::SetCanRecordBase(canRecord);
|
||||
TelemetryScalar::SetCanRecordBase(canRecord);
|
||||
TelemetryEvent::SetCanRecordBase(canRecord);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1882,6 +1884,7 @@ NS_IMETHODIMP
|
||||
TelemetryImpl::SetCanRecordExtended(bool canRecord) {
|
||||
TelemetryHistogram::SetCanRecordExtended(canRecord);
|
||||
TelemetryScalar::SetCanRecordExtended(canRecord);
|
||||
TelemetryEvent::SetCanRecordExtended(canRecord);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1915,6 +1918,9 @@ TelemetryImpl::CreateTelemetryInstance()
|
||||
// Only record scalars from the parent process.
|
||||
TelemetryScalar::InitializeGlobalState(XRE_IsParentProcess(), XRE_IsParentProcess());
|
||||
|
||||
// Only record events from the parent process.
|
||||
TelemetryEvent::InitializeGlobalState(XRE_IsParentProcess(), XRE_IsParentProcess());
|
||||
|
||||
// Now, create and initialize the Telemetry global state.
|
||||
sTelemetry = new TelemetryImpl();
|
||||
|
||||
@@ -1940,6 +1946,7 @@ TelemetryImpl::ShutdownTelemetry()
|
||||
// so as to release any heap storage that would otherwise be kept alive by it.
|
||||
TelemetryHistogram::DeInitializeGlobalState();
|
||||
TelemetryScalar::DeInitializeGlobalState();
|
||||
TelemetryEvent::DeInitializeGlobalState();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2304,13 +2311,7 @@ TelemetryImpl::GetFileIOReports(JSContext *cx, JS::MutableHandleValue ret)
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::MsSinceProcessStart(double* aResult)
|
||||
{
|
||||
bool error;
|
||||
*aResult = (TimeStamp::NowLoRes() -
|
||||
TimeStamp::ProcessCreation(error)).ToMilliseconds();
|
||||
if (error) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return NS_OK;
|
||||
return Telemetry::Common::MsSinceProcessStart(aResult);
|
||||
}
|
||||
|
||||
// Telemetry Scalars IDL Implementation
|
||||
@@ -2376,6 +2377,31 @@ TelemetryImpl::ClearScalars()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Telemetry Event IDL implementation.
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::RecordEvent(const nsACString & aCategory, const nsACString & aMethod,
|
||||
const nsACString & aObject, JS::HandleValue aValue,
|
||||
JS::HandleValue aExtra, JSContext* aCx, uint8_t optional_argc)
|
||||
{
|
||||
return TelemetryEvent::RecordEvent(aCategory, aMethod, aObject, aValue, aExtra, aCx, optional_argc);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::SnapshotBuiltinEvents(uint32_t aDataset, bool aClear, JSContext* aCx,
|
||||
uint8_t optional_argc, JS::MutableHandleValue aResult)
|
||||
{
|
||||
return TelemetryEvent::CreateSnapshots(aDataset, aClear, aCx, optional_argc, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::ClearEvents()
|
||||
{
|
||||
TelemetryEvent::ClearEvents();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::FlushBatchedChildTelemetry()
|
||||
{
|
||||
@@ -2414,6 +2440,7 @@ TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
|
||||
n += TelemetryHistogram::GetHistogramSizesofIncludingThis(aMallocSizeOf);
|
||||
n += TelemetryScalar::GetScalarSizesOfIncludingThis(aMallocSizeOf);
|
||||
n += TelemetryEvent::SizeOfIncludingThis(aMallocSizeOf);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user