Skip to content

Commit 3b4160a

Browse files
committed
Bug 2004919 - Remove temp-fog-initial-state ping (and its data) r=chutten
Differential Revision: https://phabricator.services.mozilla.com/D275619
1 parent 3c2aff6 commit 3b4160a

File tree

4 files changed

+2
-272
lines changed

4 files changed

+2
-272
lines changed

toolkit/components/glean/metrics.yaml

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ fog:
6666
- glean-team@mozilla.com
6767
expires: never
6868
send_in_pings:
69-
- temp-fog-initial-state
7069
- metrics
7170
- health
7271

@@ -86,77 +85,6 @@ fog:
8685
- glean-team@mozilla.com
8786
expires: never
8887

89-
data_directory_info:
90-
type: object
91-
description: |
92-
Information about the data directories and files used by FOG.
93-
94-
Structure is an array of objects, each containing the following properties:
95-
- `dir_name`: The name of the directory. This is the subdirectory name relative to the
96-
FOG data directory and should only include "db", "events", and "pending_pings".
97-
- `dir_exists`: Whether the directory exists. This should only be false on the first
98-
run of FOG, or if the directory was deleted.
99-
- `dir_created`: The creation time of the directory, in seconds since the unix epoch. If
100-
the directory does not exist, this will be `null` and if the time cannot be determined,
101-
it will default to `0`.
102-
- `dir_modified`: The last modification time of the directory, in seconds since the unix
103-
epoch. If the directory does not exist, this will be `null` and if the time cannot be
104-
determined, it will default to `0`.
105-
- `file_count`: The number of files in the directory. If the directory does not exist,
106-
this will be `0`.
107-
- `files`: An array of objects, each containing:
108-
- `file_name`: The name of the file. Could be `data.safe.bin`, `events.safe.bin`, or
109-
A uuid representing the doc-id of a pending ping.
110-
- `file_created`: The creation time of the file, in seconds since the epoch. If the
111-
file does not exist, this will be `null` and if the time cannot be determined, it
112-
will default to `0`.
113-
- `file_modified`: The last modification time of the file, in seconds since the epoch.
114-
If the file does not exist, this will be `null` and if the time cannot be determined,
115-
it will default to `0`.
116-
- `file_size`: The size of the file in bytes. This can be just about any size but a
117-
`0` value indicates the file is empty.
118-
notification_emails:
119-
- glean-team@mozilla.org
120-
- tlong@mozilla.com
121-
bugs:
122-
- https://bugzilla.mozilla.org/show_bug.cgi?id=1979075
123-
data_reviews:
124-
- https://bugzilla.mozilla.org/show_bug.cgi?id=1979075
125-
data_sensitivity:
126-
- technical
127-
expires: 150
128-
send_in_pings:
129-
- temp-fog-initial-state
130-
- metrics
131-
structure:
132-
type: array
133-
items:
134-
type: object
135-
properties:
136-
dir_name:
137-
type: string
138-
dir_exists:
139-
type: boolean
140-
dir_created:
141-
type: number
142-
dir_modified:
143-
type: number
144-
file_count:
145-
type: number
146-
files:
147-
type: array
148-
items:
149-
type: object
150-
properties:
151-
file_name:
152-
type: string
153-
file_created:
154-
type: number
155-
file_modified:
156-
type: number
157-
file_size:
158-
type: number
159-
16088
subdir_err:
16189
type: labeled_boolean
16290
description: |

toolkit/components/glean/pings.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,3 @@ dau-reporting:
4040
active: |
4141
The ping was submitted when the application became active again,
4242
which includes when the application starts.
43-
44-
temp-fog-initial-state:
45-
description: |
46-
Minimal ping sent immediately before Glean SDK initialization to measure
47-
initial state of FOG storages and other particulars about the FOG setup.
48-
include_client_id: true
49-
send_if_empty: true
50-
bugs:
51-
- https://bugzilla.mozilla.org/show_bug.cgi?id=1979075
52-
data_reviews:
53-
- https://bugzilla.mozilla.org/show_bug.cgi?id=1979075
54-
notification_emails:
55-
- glean-team@mozilla.com
56-
- tlong@mozilla.com
57-
reasons:
58-
startup: |
59-
The ping was submitted at startup, immediately before `glean::initialize`
60-
was called to initialize the Glean SDK.

toolkit/components/glean/src/init/mod.rs

Lines changed: 2 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5+
use std::env;
56
use std::ffi::{c_char, CStr, CString};
67
use std::ops::DerefMut;
78
use std::path::PathBuf;
8-
use std::time::{Duration, UNIX_EPOCH};
9-
use std::{env, fs};
9+
use std::time::Duration;
1010

1111
use firefox_on_glean::{metrics, pings};
1212
use nserror::{nsresult, NS_ERROR_FAILURE};
@@ -120,12 +120,6 @@ fn fog_init_internal(
120120
// Register all custom pings before we initialize.
121121
pings::register_pings(Some(&conf.application_id));
122122

123-
// Collect directory information for debugging purposes. Nightly only for now.
124-
if mozbuild::config::NIGHTLY_BUILD {
125-
log::debug!("Collecting FOG data directory information.");
126-
collect_directory_info(&conf.data_path);
127-
}
128-
129123
glean::initialize(conf, client_info);
130124

131125
metrics::fog::initializations.stop_and_accumulate(timer_id);
@@ -336,110 +330,6 @@ fn get_app_info() -> Result<(String, String, String, String), nsresult> {
336330
))
337331
}
338332

339-
/// Collects information about the data directories used by FOG.
340-
fn collect_directory_info(path: &PathBuf) {
341-
// List of child directories to check
342-
let subdirs = ["db", "events", "pending_pings"];
343-
let mut directories_info = metrics::fog::DataDirectoryInfoObject::new();
344-
345-
for subdir in subdirs.iter() {
346-
let dir_path = path.join(subdir);
347-
348-
// Initialize a DataDirectoryInfoObjectItem for each directory
349-
let mut directory_info = metrics::fog::DataDirectoryInfoObjectItem {
350-
dir_name: Some(subdir.to_string()),
351-
dir_exists: None,
352-
dir_created: None,
353-
dir_modified: None,
354-
file_count: None,
355-
files: Vec::new(),
356-
};
357-
358-
// Check if the directory exists
359-
if dir_path.is_dir() {
360-
directory_info.dir_exists = Some(true);
361-
362-
// Get directory metadata
363-
if let Ok(metadata) = fs::metadata(&dir_path) {
364-
if let Ok(created) = metadata.created() {
365-
directory_info.dir_created = Some(
366-
created
367-
.duration_since(UNIX_EPOCH)
368-
.unwrap_or(Duration::ZERO)
369-
.as_secs() as i64,
370-
);
371-
}
372-
if let Ok(modified) = metadata.modified() {
373-
directory_info.dir_modified = Some(
374-
modified
375-
.duration_since(UNIX_EPOCH)
376-
.unwrap_or(Duration::ZERO)
377-
.as_secs() as i64,
378-
);
379-
}
380-
}
381-
382-
// Read the directory's contents
383-
let mut file_count = 0;
384-
let Ok(entries) = fs::read_dir(&dir_path) else {
385-
metrics::fog::subdir_err.get(subdir).set(true);
386-
continue;
387-
};
388-
for entry in entries {
389-
let Ok(entry) = entry else {
390-
metrics::fog::subdir_entry_err.get(subdir).add(1);
391-
continue;
392-
};
393-
let Ok(metadata) = entry.metadata() else {
394-
metrics::fog::subdir_entry_metadata_err.get(subdir).add(1);
395-
continue;
396-
};
397-
398-
// Check if the entry is a file
399-
if metadata.is_file() {
400-
file_count += 1;
401-
402-
// Collect file details
403-
let file_size = metadata.len() as i64;
404-
let modified_time = metadata
405-
.modified()
406-
.unwrap_or(UNIX_EPOCH)
407-
.duration_since(UNIX_EPOCH)
408-
.unwrap_or(Duration::ZERO)
409-
.as_secs() as i64;
410-
411-
let creation_time = metadata
412-
.created()
413-
.unwrap_or(UNIX_EPOCH)
414-
.duration_since(UNIX_EPOCH)
415-
.unwrap_or(Duration::ZERO)
416-
.as_secs() as i64;
417-
let file_name = entry.file_name().to_string_lossy().to_string();
418-
419-
let file_info = metrics::fog::DataDirectoryInfoObjectItemItemFilesItem {
420-
file_name: Some(file_name),
421-
file_created: Some(creation_time),
422-
file_modified: Some(modified_time),
423-
file_size: Some(file_size),
424-
};
425-
426-
directory_info.files.push(file_info);
427-
}
428-
}
429-
430-
directory_info.file_count = Some(file_count as i64);
431-
} else {
432-
directory_info.dir_exists = Some(false);
433-
}
434-
435-
// Add the directory info to the final collection
436-
directories_info.push(directory_info);
437-
}
438-
439-
metrics::fog::data_directory_info.set(directories_info);
440-
pings::temp_fog_initial_state.submit(Some("startup"));
441-
}
442-
443333
/// **TEST-ONLY METHOD**
444334
/// Resets FOG and the underlying Glean SDK, clearing stores.
445335
#[no_mangle]

toolkit/components/glean/tests/xpcshell/test_FOGInit.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -38,73 +38,3 @@ add_task(function test_fog_initialized_with_correct_rate_limit() {
3838
"FOG has been initialized with a ping rate limit of greater than 0."
3939
);
4040
});
41-
42-
add_task(
43-
{
44-
skip_if: () => !AppConstants.NIGHTLY_BUILD,
45-
},
46-
function test_fog_gathers_dir_info_on_startup() {
47-
Assert.deepEqual(
48-
Glean.fog.dataDirectoryInfo.testGetValue(),
49-
[
50-
{
51-
dir_name: "db",
52-
dir_exists: false,
53-
},
54-
{
55-
dir_name: "events",
56-
dir_exists: false,
57-
},
58-
{
59-
dir_name: "pending_pings",
60-
dir_exists: false,
61-
},
62-
],
63-
"Directory info was collected on first startup."
64-
);
65-
const assertNoErrs = () => {
66-
// TODO: bug 1986046 - Replace with labeled testGetValue() asserts.
67-
const subdirs = ["db", "events", "pending_pings"];
68-
for (const subdir of subdirs) {
69-
Assert.equal(null, Glean.fog.subdirErr[subdir].testGetValue());
70-
Assert.equal(null, Glean.fog.subdirEntryErr[subdir].testGetValue());
71-
Assert.equal(
72-
null,
73-
Glean.fog.subdirEntryMetadataErr[subdir].testGetValue()
74-
);
75-
}
76-
};
77-
assertNoErrs();
78-
79-
// Startup again to make sure we collect the directory info when the dirs exist.
80-
Services.fog.initializeFOG();
81-
82-
// Record an event to ensure that the directory info is updated with the next startup.
83-
Glean.testOnly.anEvent.record();
84-
85-
let dir_info = Glean.fog.dataDirectoryInfo.testGetValue();
86-
Assert.equal(dir_info[0].dir_name, "db");
87-
Assert.equal(dir_info[0].dir_exists, true);
88-
// There should be at most 2 files in the db directory, data.safe.bin and maybe data.safe.tmp
89-
Assert.lessOrEqual(dir_info[0].files.length, 2);
90-
Assert.greater(dir_info[0].files[0].file_size, 0);
91-
Assert.equal(dir_info[1].dir_name, "events");
92-
Assert.equal(dir_info[1].dir_exists, true);
93-
Assert.equal(dir_info[2].dir_name, "pending_pings");
94-
Assert.equal(dir_info[2].dir_exists, true);
95-
assertNoErrs();
96-
97-
Services.fog.initializeFOG();
98-
99-
let new_dir_info = Glean.fog.dataDirectoryInfo.testGetValue();
100-
Assert.equal(new_dir_info[1].dir_name, "events");
101-
Assert.equal(new_dir_info[1].dir_exists, true);
102-
Assert.equal(new_dir_info[1].file_count, 1);
103-
Assert.equal(new_dir_info[1].files[0].file_name, "test-ping");
104-
// On Windows the file size metadata is not synced until the file is closed.
105-
// But Glean is never shutdown in this test and so the metadata doesn't update
106-
// and the file size seen will be 0, even if the file has been written to.
107-
Assert.greaterOrEqual(new_dir_info[1].files[0].file_size, 0);
108-
assertNoErrs();
109-
}
110-
);

0 commit comments

Comments
 (0)