def test_absent_use_counter(self): # A use counter that isn't in the aggregator should still get a response from the service. # This is a side-effect of bug 1412384 channel = ping_dimensions['channel'][0] version = ping_dimensions['version'][0].split('.')[0] template_build_id = [ping_dimensions['build_id'][0][:-6]] metric = 'USE_COUNTER2_SIR_NOT_APPEARING_IN_THIS_DOCUMENT' value = { u'bucket_count': 3, u'histogram_type': 2, u'range': [1, 2], u'values': {u'0': 640, u'1': 0, u'2': 0}, u'count': 0, u'sum': 0, } expected_count = 1 for dimension, values in ping_dimensions.iteritems(): if dimension not in ['channel', 'version', 'build_id']: expected_count *= len(values) histogram_expected_count = NUM_PINGS_PER_DIMENSIONS * expected_count self._histogram('build_id', channel, version, template_build_id, metric, value, histogram_expected_count)
def test_absent_use_counter(self): # A use counter that isn't in the aggregator should still get a response from the service. # This is a side-effect of bug 1412384 channel = ping_dimensions['channel'][0] version = ping_dimensions['version'][0].split('.')[0] template_build_id = [ping_dimensions['build_id'][0][:-6]] metric = 'USE_COUNTER2_SIR_NOT_APPEARING_IN_THIS_DOCUMENT' value = { u'bucket_count': 3, u'histogram_type': 2, u'range': [1, 2], u'values': { u'0': 640, u'1': 0, u'2': 0 }, u'count': 0, u'sum': 0, } expected_count = 1 for dimension, values in ping_dimensions.iteritems(): if dimension not in ['channel', 'version', 'build_id']: expected_count *= len(values) histogram_expected_count = NUM_PINGS_PER_DIMENSIONS * expected_count self._histogram('build_id', channel, version, template_build_id, metric, value, histogram_expected_count)
def test_submission_dates_metrics(self): template_channel = set(ping_dimensions['channel']) - {"release"} template_version = [x.split('.')[0] for x in ping_dimensions['version']] template_submission_date = ping_dimensions['submission_date'] expected_count = 1 for dimension, values in ping_dimensions.iteritems(): if dimension not in ['channel', 'version', 'submission_date']: expected_count *= len(values) for channel in template_channel: for version in template_version: histogram_expected_count = NUM_PINGS_PER_DIMENSIONS * expected_count for metric, value in histograms_template.iteritems(): if value is None: continue self._histogram('submission_date', channel, version, template_submission_date, metric, value, histogram_expected_count) # Count = product(dimensions) * pings_per_dimensions # 1 Count for parent, then 1 Count for each NUM_CHILDREN_PER_PING simple_measure_expected_count = expected_count * NUM_PINGS_PER_DIMENSIONS * (NUM_CHILDREN_PER_PING + 1) for simple_measure, value in simple_measurements_template.iteritems(): if not isinstance(value, int): continue metric = '{}_{}'.format(SIMPLE_MEASURES_PREFIX, simple_measure.upper()) self._simple_measure('submission_date', channel, version, template_submission_date, metric, value, simple_measure_expected_count) # for gpu and content process, NUM_AGGREGATED_CHILD_PINGS * expected_count gets the expected number of counts # (we only add gpu and content scalars for aggregated child pings) # for parent processes, NUM_PINGS_PER_DIMENSIONS * expected_count numeric_scalar_expected_count = ((2 * NUM_AGGREGATED_CHILD_PINGS) + NUM_PINGS_PER_DIMENSIONS) * expected_count for scalar, value in scalars_template.iteritems(): if not isinstance(value, int): continue metric = '{}_{}'.format(NUMERIC_SCALARS_PREFIX, scalar.upper()) self._numeric_scalar('submission_date', channel, version, template_submission_date, metric, value, numeric_scalar_expected_count, NUMERIC_SCALAR_BUCKET, NUMERIC_SCALARS_LABELS, True) for metric, _dict in keyed_scalars_template.iteritems(): metric_name = '{}_{}'.format(NUMERIC_SCALARS_PREFIX, metric.upper()) self._keyed_numeric_scalar('submission_date', channel, version, template_submission_date, metric_name, _dict, numeric_scalar_expected_count) for metric, histograms in keyed_histograms_template.iteritems(): self._keyed_histogram('submission_date', channel, version, template_submission_date, metric, histograms, histogram_expected_count)
def test_build_id_metrics(self): template_channel = ping_dimensions['channel'] template_version = [ x.split('.')[0] for x in ping_dimensions['version'] ] template_build_id = [x[:-6] for x in ping_dimensions['build_id']] expected_count = 1 for dimension, values in ping_dimensions.iteritems(): if dimension not in ['channel', 'version', 'build_id']: expected_count *= len(values) for channel in template_channel: for version in template_version: histogram_expected_count = NUM_PINGS_PER_DIMENSIONS * expected_count for metric, value in histograms_template.iteritems(): if value is None: continue self._histogram('build_id', channel, version, template_build_id, metric, value, histogram_expected_count) # Count = product(dimensions) * pings_per_dimensions # 1 Count for parent, then 1 Count for each NUM_CHILDREN_PER_PING simple_measure_expected_count = expected_count * NUM_PINGS_PER_DIMENSIONS * ( NUM_CHILDREN_PER_PING + 1) for simple_measure, value in simple_measurements_template.iteritems( ): if not isinstance(value, int): continue metric = '{}_{}'.format(SIMPLE_MEASURES_PREFIX, simple_measure.upper()) self._simple_measure('build_id', channel, version, template_build_id, metric, value, simple_measure_expected_count) # for gpu and content process, NUM_AGGREGATED_CHILD_PINGS * expected_count gets the expected number of counts # (we only add gpu and content scalars for aggregated child pings) # for parent processes, NUM_PINGS_PER_DIMENSIONS * expected_count numeric_scalar_expected_count = ( (2 * NUM_AGGREGATED_CHILD_PINGS) + NUM_PINGS_PER_DIMENSIONS) * expected_count for scalar, value in scalars_template.iteritems(): if not isinstance(value, int): continue metric = '{}_{}'.format(NUMERIC_SCALARS_PREFIX, scalar.upper()) self._numeric_scalar('build_id', channel, version, template_build_id, metric, value, numeric_scalar_expected_count, NUMERIC_SCALAR_BUCKET, NUMERIC_SCALARS_LABELS, True) for metric, _dict in keyed_scalars_template.iteritems(): metric_name = '{}_{}'.format(NUMERIC_SCALARS_PREFIX, metric.upper()) self._keyed_numeric_scalar('build_id', channel, version, template_build_id, metric_name, _dict, numeric_scalar_expected_count) for metric, histograms in keyed_histograms_template.iteritems( ): self._keyed_histogram('build_id', channel, version, template_build_id, metric, histograms, histogram_expected_count)