Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Tiny performance improvement for putting tasks on the dispatcher ([#3318](https://github.com/mozilla/glean/pull/3318))
* Instrument the case when the `client_id.txt` file does not exist yet ([#3339](https://github.com/mozilla/glean/pull/3339))
* When a missing client ID in the database is detected, Glean now restores the backup client ID ([#3334](https://github.com/mozilla/glean/pull/3334))
* Disable the `post_init` health ping ([#3343](https://github.com/mozilla/glean/pull/3343))
* iOS
* Glean for iOS is now being built with Xcode 26.2 ([#3350](https://github.com/mozilla/glean/pull/3350))

Expand Down
13 changes: 4 additions & 9 deletions docs/user/user/collected-metrics/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> If you are looking for the metrics collected by Glean.js,
> refer to the documentation over on the [`@mozilla/glean.js`](https://github.com/mozilla/glean.js/blob/main/docs/reference/metrics.md) repository.
<!-- AUTOGENERATED BY glean_parser v18.1.0. DO NOT EDIT. -->
<!-- AUTOGENERATED BY glean_parser v18.1.1. DO NOT EDIT. -->

# Metrics

Expand Down Expand Up @@ -141,8 +141,7 @@ In addition to those built-in metrics, the following metrics are added to the pi
The purpose of the health ping is to transport all of the health
metric information. The `health` ping is automatically sent when the
application calls Glean initialize before any operations are done on
the data path with a reason of `pre_init`, and once after Glean
initialization with a reason of `post_init`.
the data path with a reason of `pre_init`.


This ping includes the [client id](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section).
Expand All @@ -158,9 +157,6 @@ This ping includes the [client id](https://mozilla.github.io/glean/book/user/pin

**Reasons this ping may be sent:**

- `post_init`: The ping was submitted after Glean initialization with the state of
Glean's data directories after rkv opened files on the data path.

- `pre_init`: The ping was submitted before Glean initialization with the state of
Glean's data directories prior to rkv opening files on the data path.

Expand All @@ -171,15 +167,14 @@ In addition to those built-in metrics, the following metrics are added to the pi

| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) |
| --- | --- | --- | --- | --- | --- | --- |
| glean.database.load_sizes |[object](https://mozilla.github.io/glean/book/user/metrics/object.html) |The size of the db file during specific phases of initialization. |[Review 1](https://bugzilla.mozilla.org/1990627)||2025-12-01 |1 |
| glean.database.rkv_load_error |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If there was an error loading the RKV database, record it. |[Bug 1815253](https://bugzilla.mozilla.org/show_bug.cgi?id=1815253)||never |1 |
| glean.database.size |[memory_distribution](https://mozilla.github.io/glean/book/user/metrics/memory_distribution.html) |The size of the database file at startup. |[Bug 1656589](https://bugzilla.mozilla.org/show_bug.cgi?id=1656589#c7)||never |1 |
| glean.database.write_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time it takes for a write-commit for the Glean database. |[Bug 1896193](https://bugzilla.mozilla.org/show_bug.cgi?id=1896193#c4)||never |1 |
| glean.error.io |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The number of times we encountered an IO error when writing a pending ping to disk. |[Bug 1686233](https://bugzilla.mozilla.org/show_bug.cgi?id=1686233#c2)||never |1 |
| glean.error.preinit_tasks_overflow |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |The number of tasks that overflowed the pre-initialization buffer. Only sent if the buffer ever overflows. In Version 0 this reported the total number of tasks enqueued. |[Bug 1609482](https://bugzilla.mozilla.org/show_bug.cgi?id=1609482#c3)||never |1 |
| glean.health.data_directory_info |[object](https://mozilla.github.io/glean/book/user/metrics/object.html) |Information about the data directories and files used by FOG. Structure is an array of objects, each containing the following properties: - `dir_name`: The name of the directory. This is the subdirectory name relative to the FOG data directory and should only include "db", "events", and "pending_pings". - `dir_exists`: Whether the directory exists. This should only be false on the first run of FOG, or if the directory was deleted. - `dir_created`: The creation time of the directory, in seconds since the unix epoch. If the directory does not exist, this will be `null` and if the time cannot be determined, it will default to `0`. - `dir_modified`: The last modification time of the directory, in seconds since the unix epoch. If the directory does not exist, this will be `null` and if the time cannot be determined, it will default to `0`. - `file_count`: The number of files in the directory. If the directory does not exist, this will be `0`. - `error_message`: If there was an error accessing the directory, this will contain a brief description of the error. If there was no error, this will be null. - `files`: An array of objects, each containing: - `file_name`: The name of the file. Could be `data.safe.bin`, `events.safe.bin`, or A UUID representing the doc-id of a pending ping. - `file_created`: The creation time of the file, in seconds since the epoch. If the file does not exist, this will be `null` and if the time cannot be determined, it will default to `0`. - `file_modified`: The last modification time of the file, in seconds since the epoch. If the file does not exist, this will be `null` and if the time cannot be determined, it will default to `0`. - `file_size`: The size of the file in bytes. This can be just about any size but a `0` value indicates the file is empty. - `error_message`: If there was an error accessing the file, this will contain a brief description of the error. If there was no error, this will be null. |[Bug 1982711](https://bugzilla.mozilla.org/show_bug.cgi?id=1982711#c3)||never |1 |
| glean.health.exception_state |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |An exceptional state was detected upon trying to load the database. Valid options are: - `empty-db` - `regen-db` - `c0ffee-in-db` - `client-id-mismatch` |[Bug 1994757](https://bugzilla.mozilla.org/show_bug.cgi?id=1994757#c2)||never |1 |
| glean.health.file_read_error |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Count of different errors that happened when trying to read the `client_id.txt` file from disk. |[Bug 1994757](https://bugzilla.mozilla.org/show_bug.cgi?id=1994757#c2)|<ul><li>parse</li><li>permission-denied</li><li>io</li><li>c0ffee-in-file</li></ul>|never |1 |
| glean.health.file_read_error |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Count of different errors that happened when trying to read the `client_id.txt` file from disk. |[Bug 1994757](https://bugzilla.mozilla.org/show_bug.cgi?id=1994757#c2)|<ul><li>parse</li><li>permission-denied</li><li>io</li><li>c0ffee-in-file</li><li>file-not-found</li></ul>|never |1 |
| glean.health.file_write_error |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Count of different errors that happened when trying to write the `client_id.txt` file to disk. |[Bug 1994757](https://bugzilla.mozilla.org/show_bug.cgi?id=1994757#c2)|<ul><li>permission-denied</li><li>io</li><li>not-found</li></ul>|never |1 |
| glean.health.init_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A running count of how many times the Glean SDK has been initialized. |[Review 1](https://bugzilla.mozilla.org/1990624)||never |1 |
| glean.health.recovered_client_id |[uuid](https://mozilla.github.io/glean/book/user/metrics/uuid.html) |A client_id recovered from a `client_id.txt` file on disk. Only expected to have a value for the exception states `empty-db`, `c0ffee-in-db` and `client-id-mismatch`. See `exception_state` for different exception states when this can happen. |[Bug 1994757](https://bugzilla.mozilla.org/show_bug.cgi?id=1994757#c2)||never |1 |
Expand Down Expand Up @@ -260,5 +255,5 @@ In addition to those built-in metrics, the following metrics are added to the pi

Data categories are [defined here](https://wiki.mozilla.org/Firefox/Data_Collection).

<!-- AUTOGENERATED BY glean_parser v18.1.0. DO NOT EDIT. -->
<!-- AUTOGENERATED BY glean_parser v18.1.1. DO NOT EDIT. -->

9 changes: 4 additions & 5 deletions glean-core/pings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ health:
The purpose of the health ping is to transport all of the health
metric information. The `health` ping is automatically sent when the
application calls Glean initialize before any operations are done on
the data path with a reason of `pre_init`, and once after Glean
initialization with a reason of `post_init`.
the data path with a reason of `pre_init`.
Comment thread
badboy marked this conversation as resolved.

Previously a second ping with reason `post_init` was sent.
This reason has been removed in Glean v66.2.0.
include_client_id: true
bugs:
- https://bugzilla.mozilla.org/1667815
Expand All @@ -122,9 +124,6 @@ health:
pre_init: |
The ping was submitted before Glean initialization with the state of
Glean's data directories prior to rkv opening files on the data path.
post_init: |
The ping was submitted after Glean initialization with the state of
Glean's data directories after rkv opened files on the data path.

deletion-request:
description: |
Expand Down
2 changes: 1 addition & 1 deletion glean-core/python/tests/test_glean.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def test_glean_shutdown(safe_httpserver):

Glean.shutdown()
wait_for_requests(safe_httpserver, n=10)
assert 12 == len(safe_httpserver.requests)
assert 11 == len(safe_httpserver.requests)


@pytest.mark.skipif(sys.platform == "win32", reason="bug 1979301: Windows failures")
Expand Down
2 changes: 1 addition & 1 deletion glean-core/python/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_recording_upload_errors_doesnt_clobber_database(tmpdir, safe_httpserver
time.sleep(0.5)
ProcessDispatcher._wait_for_last_process()

assert 3 == len(safe_httpserver.requests)
assert 2 == len(safe_httpserver.requests)

# Force a reload of the database from disk
Glean._reset()
Expand Down
50 changes: 10 additions & 40 deletions glean-core/rlb/tests/health_ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn get_pings(pings_dir: &Path) -> Vec<(String, JsonValue, Option<JsonValue>)> {
/// Some data is recorded (before and after initialization).
/// And later the whole process is shutdown.
#[test]
fn test_pre_post_init_health_pings_exist() {
fn test_pre_init_health_pings_exist() {
common::enable_test_logging();

// Create a custom configuration to use a validating uploader.
Expand All @@ -85,48 +85,22 @@ fn test_pre_post_init_health_pings_exist() {

// Check for the initialization pings.
let pings = get_pings(&tmpname.join("pending_pings"));
pings.iter().for_each(|(url, _, _)| {
println!("Ping URL: {}", url);
});
assert!(!pings.is_empty());
assert_eq!(
2,
pings
.iter()
.filter(|(url, _, _)| url.contains("health"))
.count()
);
let preinits: Vec<_> = pings
.iter()
.filter(|(url, body, _)| {
url.contains("health") && body["ping_info"]["reason"] == "pre_init"
})
.collect();
assert_eq!(1, preinits.len());

let health_pings: Vec<_> = pings
.iter()
.filter(|(url, _, _)| url.contains("health"))
.filter(|(url, _body, _)| url.contains("health"))
.collect();
assert_eq!(
1,
health_pings
.iter()
.filter(|(_, body, _)| body["ping_info"]["reason"] == "post_init")
.count()
);
assert_eq!(1, health_pings.len());

let preinit = &health_pings[0];
// Ensure both "health" pings have the same init count.
assert_eq!(
2,
health_pings
.iter()
.filter(|(_, body, _)| body["metrics"]["counter"]["glean.health.init_count"] == 1)
.count()
1,
preinit.1["metrics"]["counter"]["glean.health.init_count"]
);

let exception_state = &preinits[0].1["metrics"]["string"]["glean.health_exception_state"];
let exception_state = &preinit.1["metrics"]["string"]["glean.health_exception_state"];
assert_eq!(&JsonValue::Null, exception_state);
let exception_uuid = &preinits[0].1["metrics"]["uuid"]["glean.health_recovered_client_id"];
let exception_uuid = &preinit.1["metrics"]["uuid"]["glean.health_recovered_client_id"];
assert_eq!(&JsonValue::Null, exception_uuid);

let cfg = ConfigurationBuilder::new(true, tmpname.clone(), "health-ping-test")
Expand All @@ -140,11 +114,7 @@ fn test_pre_post_init_health_pings_exist() {
let pings = get_pings(&tmpname.join("pending_pings"));
let second_preinit: Vec<_> = pings
.iter()
.filter(|(url, body, _)| {
url.contains("health")
&& body["ping_info"]["reason"] == "pre_init"
&& body["ping_info"]["seq"] == 2
})
.filter(|(url, body, _)| url.contains("health") && body["ping_info"]["seq"] == 1)
.collect();

// We should have a second "pre_init"-reason "health" ping now.
Expand Down
2 changes: 1 addition & 1 deletion glean-core/rlb/tests/health_ping_file_overwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl net::PingUploader for ReportingUploader {

/// Test scenario: Write a client ID to the backup file and check that it's used after initialization.
#[test]
fn test_pre_post_init_health_pings_exist() {
fn test_pre_init_health_ping_exist() {
common::enable_test_logging();

// Create a custom configuration to use a validating uploader.
Expand Down
2 changes: 1 addition & 1 deletion glean-core/rlb/tests/test-shutdown-blocking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ datapath=$(mktemp -d "${tmp}/glean_long_running.XXXX")
cargo run -p glean --example long-running -- "$datapath"
count=$(ls -1q "$datapath/pending_pings" | wc -l)

if [[ "$count" -eq 2 ]]; then # Only one ping, the "health" ping is expected but it is sent twice
if [[ "$count" -eq 1 ]]; then # Only one `health` ping
echo "test result: ok."
exit 0
else
Expand Down
4 changes: 2 additions & 2 deletions glean-core/rlb/tests/test-thread-crashing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ cargo run -p glean --example crashing-threads -- "$datapath"
ret=$?
count=$(ls -1q "$datapath/pending_pings" | wc -l)

# 2x "health", 1x "prototype"
expect_count=3
# 1x "health", 1x "prototype"
expect_count=2

# We expect 1 `prototype` ping:
if [[ $ret -eq 0 ]] && [[ "$count" -eq $expect_count ]]; then
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/internal_pings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl InternalPings {
true,
enabled,
vec![],
vec!["pre_init".to_string(), "post_init".to_string()],
vec!["pre_init".to_string()],
true,
vec![],
),
Expand Down
4 changes: 0 additions & 4 deletions glean-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,6 @@ fn initialize_inner(
// a health ping with reason "pre_init".
record_dir_info_and_submit_health_ping(dir_info, "pre_init");

// Now capture a post_init snapshot of the state of Glean's data directories after initialization to send
// in a health ping with reason "post_init".
record_dir_info_and_submit_health_ping(collect_directory_info(data_path), "post_init");

let state = global_state().lock().unwrap();
if let Err(e) = state.callbacks.trigger_upload() {
log::error!("Triggering upload failed. Error: {}", e);
Expand Down