Boolean

Boolean metrics are used for reporting simple flags.

Recording API

set

Sets a boolean metric to a specific value.

import org.mozilla.yourApplication.GleanMetrics.Flags

Flags.a11yEnabled.set(System.isAccesibilityEnabled())
import org.mozilla.yourApplication.GleanMetrics.Flags;

Flags.INSTANCE.a11yEnabled.set(System.isAccessibilityEnabled());
Flags.a11yEnabled.set(self.isAccessibilityEnabled)
from glean import load_metrics
metrics = load_metrics("metrics.yaml")

metrics.flags.a11y_enabled.set(is_accessibility_enabled())
use glean_metrics;

flags::a11y_enabled.set(system.is_accessibility_enabled());
import * as flags from "./path/to/generated/files/flags.js";

flags.a11yEnabled.set(this.isAccessibilityEnabled());

C++

#include "mozilla/glean/GleanMetrics.h"

mozilla::glean::flags::a11y_enabled.Set(false);

JavaScript

Glean.flags.a11yEnabled.set(false);

Recorded errors

N/A

Testing API

testGetValue

Gets the recorded value for a given boolean metric.

import org.mozilla.yourApplication.GleanMetrics.Flags

assertTrue(Flags.a11yEnabled.testGetValue())
import org.mozilla.yourApplication.GleanMetrics.Flags;

assertTrue(Flags.INSTANCE.a11yEnabled.testGetValue());
@testable import Glean

XCTAssertTrue(try Flags.a11yEnabled.testGetValue())
from glean import load_metrics
metrics = load_metrics("metrics.yaml")

assert True is metrics.flags.a11y_enabled.test_get_value()
use glean_metrics;

assert!(flags::a11y_enabled.test_get_value(None).unwrap());
import * as flags from "./path/to/generated/files/flags.js";

assert(await flags.a11yEnabled.testGetValue());

C++

#include "mozilla/glean/GleanMetrics.h"

ASSERT_EQ(false, mozilla::glean::flags::a11y_enabled.TestGetValue().value());

JavaScript

Assert.equal(false, Glean.flags.a11yEnabled.testGetValue());

testHasValue

Whether or not any value was recorded for a given boolean metric.

import org.mozilla.yourApplication.GleanMetrics.Flags

assertTrue(Flags.a11yEnabled.testHasValue())
import org.mozilla.yourApplication.GleanMetrics.Flags;

assertTrue(Flags.INSTANCE.a11yEnabled.testHasValue());
@testable import Glean

XCTAssertTrue(try Flags.a11yEnabled.testHasValue())
from glean import load_metrics
metrics = load_metrics("metrics.yaml")

assert True is metrics.flags.a11y_enabled.test_has_value()

Metric parameters

Example boolean metric definition:

flags:
  a11y_enabled:
    type: boolean
    description: >
      Records whether a11y is enabled on the device.
    bugs:
      - https://bugzilla.mozilla.org/000000
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=000000#c3
    notification_emails:
      - me@mozilla.com
    expires: 2020-10-01

For a full reference on metrics parameters common to all metric types, refer to the metrics YAML registry format reference page.

Extra metric parameters

N/A

Data questions

  • Is accessibility enabled?

Reference