Struct metrics_controller::controller::MetricsController [] [src]

pub struct MetricsController {
    // some fields omitted
}

The metrics controller for the Connected Devices Metrics Library

Methods

impl MetricsController
[src]

fn new(app_name: &str, app_version: &str, app_update_channel: &str, app_build_id: &str, app_platform: &str, locale: &str, device: &str, arch: &str, os: &str, os_version: &str) -> MetricsController

Constructs a new MetricsController object. Caller passes information about their application and environment. This information will be associated with the metrics data recorded by the record_event function.

Examples

use metrics_controller::controller::MetricsController;
let mc = MetricsController::new(
    "foxbox".to_string(),
    "1.0".to_string(),
    "nightly".to_string(),
    "20160305".to_string(),
    "rust".to_string(),
    "en-us".to_string(),
    "raspberry-pi".to_string(),
    "arm".to_string(),
    "linux".to_string(),
    "1.2.3".to_string());

fn start_metrics(&mut self) -> bool

This function starts the metrics service, which also starts the worker thread needed to operate the metrics service. The worker thread is responsible for periodically persisting the metrics data and transmitting it to the server.

fn stop_collecting(&mut self)

This function stops the metrics service and deletes metrics data that has been collected but not sent to the server.

fn record_event(&mut self, event_category: &str, event_action: &str, event_label: &str, event_value: u64) -> bool

Constructs and records an event. The recorded events are sent to the server based on an internal schedule (when twenty events are recorded). Currently, this schedule is not configurable.

Params:

event_category - Category of the event. For example, eng or user

event_action - Action that triggered the event. For example, open-app

event_label - Label, or description, of the metric. For example, memory

event_value - Numeric value of the metric.

Returns:

true - Success

false - Unable to record the event

fn record_floating_point_event(&mut self, event_category: &str, event_action: &str, event_label: &str, event_value: f64) -> bool

Constructs and records an event with a floating point numeric value. The recorded events are sent to the server based on an internal schedule (when twenty events are recorded). Currently, this schedule is not configurable.

Params:

event_category - Category of the event. For example, eng or user

event_action - Action that triggered the event. For example, open-app

event_label - Label, or description, of the metric. For example, memory

event_value - Numeric value of the metric.

Returns:

true - Success

false - Unable to record the event