Bug 1278556 - Enable the support for "record_in_process" in Scalars.yaml. r=gfritzsche

MozReview-Commit-ID: BP2sADn0ELc
This commit is contained in:
Alessio Placitelli
2017-01-10 08:22:00 +01:00
parent 2fce804d08
commit 31eefba96d
3 changed files with 45 additions and 3 deletions

View File

@@ -6,17 +6,30 @@
#ifndef TelemetryScalarInfo_h__
#define TelemetryScalarInfo_h__
#include "nsXULAppAPI.h"
// This module is internal to Telemetry. It defines a structure that holds the
// scalar info. It should only be used by TelemetryScalarData.h automatically
// generated file and TelemetryScalar.cpp. This should not be used anywhere else.
// For the public interface to Telemetry functionality, see Telemetry.h.
namespace {
enum class RecordedProcessType : uint32_t {
Main = (1 << GeckoProcessType_Default), // Also known as "parent process"
Content = (1 << GeckoProcessType_Content),
Gpu = (1 << GeckoProcessType_GPU),
AllChilds = 0xFFFFFFFF - 1, // All the children processes (i.e. content, gpu, ...)
All = 0xFFFFFFFF // All the processes
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RecordedProcessType)
struct ScalarInfo {
uint32_t kind;
uint32_t name_offset;
uint32_t expiration_offset;
uint32_t dataset;
RecordedProcessType record_in_processes;
bool keyed;
const char *name() const;

View File

@@ -40,11 +40,12 @@ def write_scalar_info(scalar, output, name_index, expiration_index):
if cpp_guard:
print("#if defined(%s)" % cpp_guard, file=output)
print(" {{ {}, {}, {}, {}, {} }},"\
print(" {{ {}, {}, {}, {}, {}, {} }},"\
.format(scalar.nsITelemetry_kind,
name_index,
expiration_index,
scalar.dataset,
" | ".join(scalar.record_in_processes_enum),
"true" if scalar.keyed else "false"),
file=output)

View File

@@ -14,6 +14,16 @@ SCALAR_TYPES_MAP = {
'boolean': 'nsITelemetry::SCALAR_BOOLEAN'
}
# This is a list of flags that determine which process the scalar is allowed
# to record from.
KNOWN_PROCESS_FLAGS = {
'all': 'RecordedProcessType::All',
'all_childs': 'RecordedProcessType::AllChilds',
'main': 'RecordedProcessType::Main',
'content': 'RecordedProcessType::Content',
'gpu': 'RecordedProcessType::Gpu',
}
class ScalarType:
"""A class for representing a scalar definition."""
@@ -87,13 +97,15 @@ class ScalarType:
OPTIONAL_FIELDS = {
'cpp_guard': basestring,
'release_channel_collection': basestring,
'keyed': bool
'keyed': bool,
'record_in_processes': list,
}
# The types for the data within the fields that hold lists.
LIST_FIELDS_CONTENT = {
'bug_numbers': int,
'notification_emails': basestring
'notification_emails': basestring,
'record_in_processes': basestring,
}
# Concatenate the required and optional field definitions.
@@ -153,6 +165,12 @@ class ScalarType:
if cpp_guard and re.match(r'\W', cpp_guard):
raise ValueError(self._name + ' - invalid cpp_guard: ' + cpp_guard)
# Validate record_in_processes.
record_in_processes = definition.get('record_in_processes', [])
for proc in record_in_processes:
if proc not in KNOWN_PROCESS_FLAGS.keys():
raise ValueError(self._name + ' - unknown value in record_in_processes: ' + proc)
@property
def name(self):
"""Get the scalar name"""
@@ -208,6 +226,16 @@ class ScalarType:
"""Get the list of notification emails"""
return self._definition['notification_emails']
@property
def record_in_processes(self):
"""Get the non-empty list of processes to record data in"""
return self._definition.get('record_in_processes', ['main'])
@property
def record_in_processes_enum(self):
"""Get the non-empty list of flags representing the processes to record data in"""
return [KNOWN_PROCESS_FLAGS.get(p) for p in self.record_in_processes]
@property
def dataset(self):
"""Get the nsITelemetry constant equivalent to the chose release channel collection