Skip to content

Commit 8638eeb

Browse files
author
Mike Trinkala
authored
Merge pull request #169 from sunahsuh/experiments-filtering
Bug 1381954: Filter out non-whitelisted experiment types and blocklisted experimen…
2 parents 985ff60 + 61208ef commit 8638eeb

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

moz_telemetry/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
cmake_minimum_required(VERSION 3.0)
6-
project(moz-telemetry VERSION 1.2.14 LANGUAGES C)
6+
project(moz-telemetry VERSION 1.2.15 LANGUAGES C)
77
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mozilla Firefox Telemetry Data Processing")
88
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${PACKAGE_PREFIX}-moz-ingest (>= 0.0.1), ${PACKAGE_PREFIX}-lsb (>= 1.1.0), ${PACKAGE_PREFIX}-circular-buffer (>= 1.0.2), ${PACKAGE_PREFIX}-heka (>= 1.1.9), ${PACKAGE_PREFIX}-elasticsearch (>= 1.0.3), ${PACKAGE_PREFIX}-rjson (>= 1.1.0), ${PACKAGE_PREFIX}-lfs (>= 1.6.4)")
99
string(REGEX REPLACE "[()]" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_DEBIAN_PACKAGE_DEPENDS})

moz_telemetry/sandboxes/heka/output/moz_telemetry_s3.lua

+20-4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ preserve_data = not flush_on_shutdown -- should always be the inverse of f
4949
5050
-- Specify an optional module to encode incoming messages via its encode function.
5151
-- encoder_module = "encoders.heka.framed_protobuf" -- default
52+
53+
-- Specifies experiment types whitelist, and experiment id blocklist
54+
experiment_types = {["normandy-preference-"] = true} -- optional
55+
experiment_blocklist = {["pref-flip-screenshots-release-1369150"] = true} -- optional
5256
```
5357
--]]
5458

@@ -85,6 +89,10 @@ if experiment_dimensions then
8589
experiment_batch_dir = read_config("experiment_batch_dir") or error("experiment_batch_dir must be specified")
8690
experiment_dimensions = mts3.validate_dimensions(experiment_dimensions)
8791
end
92+
local experiment_types = read_config("experiment_types") or {}
93+
assert(type(experiment_types) == "table", "experiment_types must be a table")
94+
local experiment_blocklist = read_config("experiment_blocklist") or {}
95+
assert(type(experiment_blocklist) == "table", "experiment_blocklist must be a table")
8896

8997

9098
local function get_fqfn(dir, path)
@@ -190,6 +198,12 @@ local function process_standard_dimensions(data)
190198
end
191199

192200

201+
local function does_experiment_qualify(id, branch, experimentType)
202+
return (not experimentType or experiment_types[experimentType])
203+
and not experiment_blocklist[id]
204+
end
205+
206+
193207
local function process_experiment_dimensions(data, experiments)
194208
local ok, experiments = pcall(cjson.decode, experiments)
195209
if not ok then return end
@@ -198,11 +212,13 @@ local function process_experiment_dimensions(data, experiments)
198212
for id, exp in pairs(experiments) do
199213
vars.experimentId = id
200214
vars.experimentBranch = exp.branch
201-
local dims = {}
202-
for i,d in ipairs(experiment_dimensions) do
203-
dims[i] = mts3.read_dimension(d, vars)
215+
if does_experiment_qualify(id, exp.branch, exp.type) then
216+
local dims = {}
217+
for i,d in ipairs(experiment_dimensions) do
218+
dims[i] = mts3.read_dimension(d, vars)
219+
end
220+
output_dimension(experiment_batch_dir, dims, data)
204221
end
205-
output_dimension(experiment_batch_dir, dims, data)
206222
end
207223
end
208224

moz_telemetry/tests/hindsight/run/input/moz_telemetry_s3.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ require "string"
1212
local inputs = {
1313
{Timestamp = 0, Type = "moz_telemetry_s3", Fields = { docType = "main"}},
1414
{Timestamp = 0, Type = "moz_telemetry_s3", Fields = { docType = "main", ["environment.experiments"] = '{"foo":{"branch":"123"}}'}},
15-
{Timestamp = 0, Type = "moz_telemetry_s3", Fields = { docType = "main", ["environment.experiments"] = '{"foo":{"branch":"123"}, "bar":{"branch":"456"}}'}}
15+
{Timestamp = 0, Type = "moz_telemetry_s3", Fields = { docType = "main", ["environment.experiments"] = '{"foo":{"branch":"123"}, "bar":{"branch":"456"}}'}},
16+
{Timestamp = 0, Type = "moz_telemetry_s3", Fields = { docType = "main", ["environment.experiments"] = '{"foo":{"branch":"123", "type":"normandy-preference-"}, "bar":{"branch":"456", "type":"another-type"}, "pref-flip-screenshots-release-1369150":{"branch":"789"}}'}}
1617
}
1718

1819

@@ -46,9 +47,10 @@ function process_message()
4647
local ed = eh:read("*a")
4748
eh:close()
4849

49-
if od:match("main\n") and ed:match("main%+foo%+123") and ed:match("main%+bar%+456") then
50-
check_message_count("output/moz_telemetry_s3/main", 3)
51-
check_message_count("output/moz_experiments_s3/main+foo+123", 2)
50+
if od:match("main\n") and ed:match("main%+foo%+123") and ed:match("main%+bar%+456")
51+
and not ed:match("main%+pref-flip-screenshots-release-1369150%+789") then
52+
check_message_count("output/moz_telemetry_s3/main", 4)
53+
check_message_count("output/moz_experiments_s3/main+foo+123", 3)
5254
check_message_count("output/moz_experiments_s3/main+bar+456", 1)
5355
return 0
5456
end

moz_telemetry/tests/hindsight/run/output/moz_telemetry_s3.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ dimension_file = "moz_telemetry_s3.json"
88

99
-- https://bugzilla.mozilla.org/show_bug.cgi?id=1353110
1010
experiment_dimension_file = "moz_telemetry_s3_experiments.json" -- optional
11+
experiment_types = {["normandy-preference-"] = true} -- optional
12+
experiment_blocklist = {["pref-flip-screenshots-release-1369150"] = true} -- optional
1113

1214
-- directory location to store the intermediate output files
1315
batch_dir = "output/moz_telemetry_s3"

0 commit comments

Comments
 (0)