Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1229083 - Add missing level to AddonHistograms. r=marshall.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamarahills committed Dec 14, 2015
1 parent 2e76e29 commit f631b2a
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 68 deletions.
24 changes: 14 additions & 10 deletions apps/system/js/advanced_telemetry.js
Expand Up @@ -96,7 +96,7 @@
var array = longLine.match(/.{1,1000}/g);
// Output each chunk to the console
array.forEach(function (value) {
console.log(AT_DEBUG_PREFIX + value);
console.log(value);
});
} else {
// Its < what ADB can handle so just output it normally.
Expand Down Expand Up @@ -430,9 +430,10 @@
// Merge the new metrics into the old metrics and then transmit the
// result to the server.
function mergePayloads(payloadOld, payloadNew) {
mergeKeyed(payloadOld.keyedHistograms, payloadOld, payloadNew);
mergeLists(payloadOld.addonHistograms,
payloadNew.addonHistograms);
mergeHistogramType(payloadOld.keyedHistograms, payloadOld, payloadNew,
'keyedHistograms');
mergeHistogramType(payloadOld.addonHistograms, payloadOld, payloadNew,
'addonHistograms');
return payloadOld;
}
});
Expand Down Expand Up @@ -464,15 +465,15 @@
}
}

function mergeKeyed(keyedOldHist, payloadOld, payloadNew) {
function mergeHistogramType(oldHist, payloadOld, payloadNew, histType) {
var keyedOldMapKeys = new Map();

for (var keyOld in keyedOldHist) {
keyedOldMapKeys.set(keyOld, keyedOldHist[keyOld]);
for (var keyOld in oldHist) {
keyedOldMapKeys.set(keyOld, oldHist[keyOld]);
}

var keyedNew = payloadNew.keyedHistograms;
var keyedOld = payloadOld.keyedHistograms;
var keyedNew = payloadNew[histType];
var keyedOld = payloadOld[histType];
for (var keyNew in keyedNew) {
if (keyedOldMapKeys.has(keyNew)) {
mergeLists(keyedOld[keyNew], keyedNew[keyNew]);
Expand Down Expand Up @@ -574,7 +575,10 @@

// Pack the Addon Histograms.
for (var addon in nameAddonHist) {
nameAddonHist[addon] = this.packHistogram(nameAddonHist[addon]);
for (var hist in nameAddonHist[addon]) {
nameAddonHist[addon][hist] =
this.packHistogram(nameAddonHist[addon][hist]);
}
}

// Pack the Keyed Histograms.
Expand Down
130 changes: 72 additions & 58 deletions apps/system/test/unit/advanced_telemetry_test.js
Expand Up @@ -65,15 +65,17 @@ suite('AdvancedTelemetry:', function() {
}
},
addonHistograms: {
COMM_SMS: {
min: 1,
max: 1000,
histogram_type:0,
sum:58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0,1,2,5,12,29,70,170,412,1000],
counts:[0,0,0,0,4,0,0,0,0,0]
addon1: {
COMM_SMS: {
min: 1,
max: 1000,
histogram_type: 0,
sum: 58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0, 1, 2, 5, 12, 29, 70, 170, 412, 1000],
counts: [0, 0, 0, 0, 4, 0, 0, 0, 0, 0]
}
}
}
};
Expand Down Expand Up @@ -158,25 +160,29 @@ suite('AdvancedTelemetry:', function() {
}
},
addonHistograms: {
COMM_SMS: {
min: 1,
max: 1000,
histogram_type:0,
sum:58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0,1,2,5,12,29,70,170,412,1000],
counts:[0,0,0,0,4,0,0,0,0,0]
addon1: {
COMM_SMS: {
min: 1,
max: 1000,
histogram_type: 0,
sum: 58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0, 1, 2, 5, 12, 29, 70, 170, 412, 1000],
counts: [0, 0, 0, 0, 4, 0, 0, 0, 0, 0]
}
},
COMM_DIALER: {
min: 1,
max: 1000,
histogram_type:0,
sum:58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0,1,2,5,12,29,70,170,412,1000],
counts:[0,0,0,0,4,0,0,0,0,0]
addon2: {
COMM_DIALER: {
min: 1,
max: 1000,
histogram_type: 0,
sum: 58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0, 1, 2, 5, 12, 29, 70, 170, 412, 1000],
counts: [0, 0, 0, 0, 4, 0, 0, 0, 0, 0]
}
}
}
};
Expand Down Expand Up @@ -241,20 +247,24 @@ suite('AdvancedTelemetry:', function() {
}
},
addonHistograms:{
COMM_SMS:{
min:1,max:1000,histogram_type:0,
sum:116,
log_sum:21.871920108795166,
log_sum_squares:59.90799617767334,
ranges:[0,1,2,5,12,29,70,170,412,1000],
counts:[0,0,0,0,8,0,0,0,0,0]},
COMM_DIALER:{
min:1,max:1000,histogram_type:0,
sum:58,
log_sum:10.935960054397583,
log_sum_squares:29.95399808883667,
ranges:[0,1,2,5,12,29,70,170,412,1000],
counts:[0,0,0,0,4,0,0,0,0,0]}
addon1: {
COMM_SMS: {
min: 1, max: 1000, histogram_type: 0,
sum: 116,
log_sum: 21.871920108795166,
log_sum_squares: 59.90799617767334,
ranges: [0, 1, 2, 5, 12, 29, 70, 170, 412, 1000],
counts: [0, 0, 0, 0, 8, 0, 0, 0, 0, 0]}
},
addon2: {
COMM_DIALER: {
min: 1, max: 1000, histogram_type: 0,
sum: 58,
log_sum: 10.935960054397583,
log_sum_squares: 29.95399808883667,
ranges: [0, 1, 2, 5, 12, 29, 70, 170, 412, 1000],
counts: [0, 0, 0, 0, 4, 0, 0, 0, 0, 0]}
}
}
};

Expand Down Expand Up @@ -342,15 +352,17 @@ suite('AdvancedTelemetry:', function() {
}
},
addonHistograms: {
rn_metric: {
min: 1,
max: 10000,
histogram_type: 1,
sum: 99,
sum_squares_lo: 9801,
sum_squares_hi: 0,
ranges: [0, 1, 1251, 2501, 3751, 5001, 6250, 7500, 8750, 10000],
counts: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
addon3: {
rn_metric: {
min: 1,
max: 10000,
histogram_type: 1,
sum: 99,
sum_squares_lo: 9801,
sum_squares_hi: 0,
ranges: [0, 1, 1251, 2501, 3751, 5001, 6250, 7500, 8750, 10000],
counts: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
}
}
}
}
Expand Down Expand Up @@ -387,14 +399,16 @@ suite('AdvancedTelemetry:', function() {
}
},
addonHistograms: {
rn_metric: {
range: [1, 10000],
bucket_count:10,
histogram_type:1,
values:{'0':0, '1':1, '1251':0},
sum: 99,
sum_squares_lo:9801,
sum_squares_hi:0
addon3: {
rn_metric: {
range: [1, 10000],
bucket_count: 10,
histogram_type: 1,
values: {'0': 0, '1': 1, '1251': 0},
sum: 99,
sum_squares_lo: 9801,
sum_squares_hi: 0
}
}
}
}
Expand Down

0 comments on commit f631b2a

Please sign in to comment.