Crate glean

Source
Expand description

Glean is a modern approach for recording and sending Telemetry data.

It’s in use at Mozilla.

All documentation can be found online:

§The Glean SDK Book

§Example

Initialize Glean, register a ping and then send it.

let cfg = ConfigurationBuilder::new(true, "/tmp/data", "org.mozilla.glean_core.example").build();
glean::initialize(cfg, ClientInfoMetrics::unknown());

let prototype_ping = PingType::new("prototype", true, true, true, true, true, vec!(), vec!(), true, vec![]);

prototype_ping.submit(None);

Modules§

net
Handling the Glean upload logic.
private
The different metric types supported by the Glean SDK to handle data.
traits
API definitions for the different metric types supported by the Glean SDK.

Structs§

AttributionMetrics
Optional product attribution metrics carried in client_info.attribution.
ClientInfoMetrics
Metrics included in every ping as client_info.
CommonMetricData
The common set of data shared across all different metric types.
Configuration
The Glean configuration.
ConfigurationBuilder
Configuration builder.
Datetime
Representation of a date, time and timezone.
DistributionData
A snapshot of all buckets and the accumulated sum of a distribution.
DistributionMetrics
Optional product distribution metrics carried in client_info.distribution.
Error
A specialized Error type for this crate’s operations.
Glean
The object holding meta information about a Glean instance.
PingRateLimit
How to specify the rate at which pings may be uploaded before they are throttled.
Rate
A rate value as given by its numerator and denominator.
RecordedEvent
Represents the recorded data for a single event.
RecordedExperiment
Deserialized experiment data.
TimerId
Identifier for a running timer.

Enums§

ErrorType
The possible error types for metric recording.
HistogramType
Different kinds of histograms.
LabeledMetricData
The metric data needed to construct inner submetrics.
Lifetime
The supported metrics’ lifetimes.
MemoryUnit
Different resolutions supported by the memory related metric types (e.g. MemoryDistributionMetric).
TimeUnit
Different resolutions supported by the time related metric types (e.g. DatetimeMetric).

Traits§

MetricIdentifier
A MetricIdentifier describes an interface for retrieving an identifier (category, name, label) for a metric

Functions§

get_registered_ping_names
Gets a list of currently registered ping names.
get_timestamp_ms
Returns a timestamp corresponding to “now” with millisecond precision.
glean_apply_server_knobs_config
Set the remote configuration values for the metrics’ disabled property
glean_get_debug_view_tag
Gets the currently set debug view tag.
glean_get_log_pings
Gets the current log pings value.
handle_client_active
Performs the collection/cleanup operations required by becoming active.
handle_client_inactive
Performs the collection/cleanup operations required by becoming inactive.
initialize
Creates and initializes a new Glean object.
persist_ping_lifetime_data
Asks the database to persist ping-lifetime data to disk.
set_collection_enabled
Sets whether upload is enabled or not.
set_debug_view_tag
Sets a debug view tag.
set_experiment_active
Indicate that an experiment is running. Glean will then add an experiment annotation to the environment which is sent with pings. This infomration is not persisted between runs.
set_experiment_inactive
Indicate that an experiment is no longer running.
set_experimentation_id
Dynamically set the experimentation identifier, as opposed to setting it through the configuration during initialization.
set_log_pings
Sets the log pings debug option.
set_source_tags
Sets source tags.
set_upload_enabled
DEPRECATED Sets whether upload is enabled or not.
shutdown
Shuts down Glean in an orderly fashion.
submit_ping_by_name
Collects and submits a ping for eventual uploading by name.
test_get_attribution
TEST-ONLY Method
test_get_distribution
TEST-ONLY Method
test_get_experiment_data
TEST ONLY FUNCTION. Returns the RecordedExperiment for the given experiment_id or panics if the id isn’t found.
test_get_experimentation_id
TEST ONLY FUNCTION. Gets stored experimentation id.
test_is_experiment_active
TEST ONLY FUNCTION. Checks if an experiment is currently active.
test_reset_glean
TEST ONLY FUNCTION. Resets the Glean state and triggers init again.
update_attribution
Updates attribution fields with new values. AttributionMetrics fields with None values will not overwrite older values.
update_distribution
Updates distribution fields with new values. DistributionMetrics fields with None values will not overwrite older values.

Type Aliases§

Result
A specialized Result type for this crate’s operations.