Beispiel #1
0
def extract_histogram_data(histogram):
    props = {
        # source_field: target_field
        "cpp_guard": "cpp_guard",
        "description": "description",
        "expiration": "expiry_version",
        "bug_numbers": "bug_numbers",
        "n_buckets": "details/n_buckets",
        "low": "details/low",
        "high": "details/high",
        "keyed": "details/keyed",
        "kind": "details/kind",
    }

    defaults = {
        "cpp_guard": None,
        "keyed": False,
        "expiration": "never",
        "bug_numbers": [],
    }

    data = {"details": {}}

    for source_field, target_field in props.iteritems():
        value = None
        if hasattr(histogram, source_field):
            value = getattr(histogram, source_field)()
        elif source_field in histogram._definition:
            value = histogram._definition.get(source_field)
        elif source_field in defaults:
            value = defaults[source_field]
        set_in_nested_dict(data, target_field, value)

    # We only care about opt-out or opt-in really.
    optout = False
    if hasattr(histogram, "dataset"):
        optout = getattr(histogram, "dataset")().endswith('_OPTOUT')
    data["optout"] = optout

    # Normalize some field values.
    data["expiry_version"] = get_major_version(data["expiry_version"])
    if data["expiry_version"] == "default":
        data["expiry_version"] = "never"
    if data["details"]["keyed"] == "true":
        data["details"]["keyed"] = True

    # TODO: Fixup old non-number values & expressions.
    # History: bug 920169, bug 1245910
    # "JS::gcreason::NUM_TELEMETRY_REASONS"
    # "JS::gcreason::NUM_TELEMETRY_REASONS+1"
    # "mozilla::StartupTimeline::MAX_EVENT_ID"

    return data
Beispiel #2
0
def extract_histogram_data(histogram):
    props = {
        # source_field: target_field
        "cpp_guard": "cpp_guard",
        "description": "description",
        "expiration": "expiry_version",

        "n_buckets": "details/n_buckets",
        "low": "details/low",
        "high": "details/high",
        "keyed": "details/keyed",
        "kind": "details/kind",
    }

    defaults = {
        "cpp_guard": None,
        "keyed": False,
        "expiration": "never",
    }

    data = {
        "details": {}
    }

    for source_field, target_field in props.iteritems():
        value = None
        if hasattr(histogram, source_field):
            value = getattr(histogram, source_field)()
        elif source_field in defaults:
            value = defaults[source_field]
        set_in_nested_dict(data, target_field, value)

    # We only care about opt-out or opt-in really.
    optout = False
    if hasattr(histogram, "dataset"):
        optout = getattr(histogram, "dataset")().endswith('_OPTOUT')
    data["optout"] = optout

    # Normalize some field values.
    data["expiry_version"] = get_major_version(data["expiry_version"])
    if data["expiry_version"] == "default":
        data["expiry_version"] = "never"
    if data["details"]["keyed"] == "true":
        data["details"]["keyed"] = True

    # TODO: Fixup old non-number values & expressions.
    # History: bug 920169, bug 1245910
    # "JS::gcreason::NUM_TELEMETRY_REASONS"
    # "JS::gcreason::NUM_TELEMETRY_REASONS+1"
    # "mozilla::StartupTimeline::MAX_EVENT_ID"

    return data
Beispiel #3
0
def extract_events_data(e):
    props = {
        # source_field: target_field

        # TODO: extract description.
        "description": "description",
        "expiry_version": "expiry_version",
        "expiry_day": "expiry_day",
        "cpp_guard": "cpp_guard",
        "bug_numbers": "bug_numbers",

        "methods": "details/methods",
        "objects": "details/objects",
        "record_in_processes": "details/record_in_processes",
        # TODO: extract key descriptions too.
        "extra_keys": "details/extra_keys",
    }

    defaults = {
        "expiry_version": "never",
        "expiry_day": "never",
        "name": e.methods[0],
        "description": e.description,
        "cpp_guard": None,
        "bug_numbers": [],
    }

    data = {
        "details": {}
    }

    for source_field, target_field in props.iteritems():
        value = getattr(e, source_field, e._definition.get(source_field, None))
        if value is None and source_field in defaults:
            value = defaults[source_field]
        set_in_nested_dict(data, target_field, value)

    # We only care about opt-out or opt-in really.
    optout = getattr(e, "dataset", "").endswith('_OPTOUT')
    data["optout"] = optout

    # Normalize some field values.
    data["expiry_version"] = get_major_version(data["expiry_version"])
    if data["expiry_version"] == "default":
        data["expiry_version"] = "never"

    return data
Beispiel #4
0
def extract_events_data(e):
    props = {
        # source_field: target_field

        # TODO: extract description.
        "description": "description",
        "expiry_version": "expiry_version",
        "expiry_day": "expiry_day",
        "cpp_guard": "cpp_guard",

        "methods": "details/methods",
        "objects": "details/objects",
        "record_in_processes": "details/record_in_processes",
        # TODO: extract key descriptions too.
        "extra_keys": "details/extra_keys",
    }

    defaults = {
        "expiry_version": "never",
        "expiry_day": "never",
        "name": e.methods[0],
        "description": e.description,
        "cpp_guard": None,
    }

    data = {
        "details": {}
    }

    for source_field, target_field in props.iteritems():
        value = getattr(e, source_field, None)
        if value is None and source_field in defaults:
            value = defaults[source_field]
        set_in_nested_dict(data, target_field, value)

    # We only care about opt-out or opt-in really.
    optout = getattr(e, "dataset", "").endswith('_OPTOUT')
    data["optout"] = optout

    # Normalize some field values.
    data["expiry_version"] = get_major_version(data["expiry_version"])
    if data["expiry_version"] == "default":
        data["expiry_version"] = "never"

    return data
Beispiel #5
0
def extract_scalar_data(s):

    # External scalars.yaml files have release/prerelease, not opt-in/opt-out
    try:
        optout = s.dataset.endswith('_OPTOUT')
    except KeyError:
        optout = s._definition.get('collect_on_channels',
                                   'prerelease') == 'release'

    return {
        "description": s.description,
        "expiry_version": get_major_version(s.expires),
        "cpp_guard": s.cpp_guard,
        "optout": optout,
        "details": {
            "keyed": s.keyed,
            "kind": s.kind,
            "record_in_processes": s.record_in_processes
        }
    }