Bug 1643395 - Allow configuring FOG server to localhost via pref r=janerik

Differential Revision: https://phabricator.services.mozilla.com/D78347
This commit is contained in:
Chris H-C 2020-06-05 12:52:20 +00:00
Родитель 02f426220f
Коммит 0ab50d164c
4 изменённых файлов: 28 добавлений и 1 удалений

Просмотреть файл

@ -8751,6 +8751,12 @@
value: 300000
mirror: always
- name: telemetry.fog.test.localhost_port
type: RelaxedAtomicUint32
value: 0
mirror: always
rust: true
#---------------------------------------------------------------------------
# Prefs starting with "test."
#---------------------------------------------------------------------------

Просмотреть файл

@ -1,7 +1,15 @@
# Preferences
## Test-only Preferences
`telemetry.fog.temporary_and_just_for_testing.data_path`
This controls the data path Glean is initialized with (`nightly` only).
It is intended for manual testing only. It will be removed once FOG gets a fixed data path.
By default it is not set. Change requires restart.
`telemetry.fog.test.localhost_port`
If set to a value `port` which is greater than 0, pings will be sent to
`http://localhost:port` instead of `https://incoming.telemetry.mozilla.org`.
Defaults to 0.

Просмотреть файл

@ -3,6 +3,12 @@
Given the multiple API languages, processes, and dependencies,
testing FOG is a matter of choosing the right tool for the situation.
## Logging
An often-overlooked first line of testing is "what do the logs say?".
To turn on logging for FOG, run Firefox with `RUST_LOG="glean,fog"`.
This will also turn on logging for `glean_core` which is often illuminating.
## Rust
Not all of our Rust code can be tested in a single fashion, unfortunately.

Просмотреть файл

@ -148,7 +148,14 @@ fn register_uploader() {
);
let result: std::result::Result<UploadResult, viaduct::Error> = (move || {
const SERVER: &str = "https://incoming.telemetry.mozilla.org";
let url = Url::parse(SERVER)?.join(&ping_request.path)?;
let mut server = String::from(SERVER);
let localhost_port = static_prefs::pref!("telemetry.fog.test.localhost_port");
if localhost_port > 0 {
server = format!("http://localhost:{}", localhost_port);
}
let url = Url::parse(&server)?.join(&ping_request.path)?;
log::info!("FOG Ping uploader uploading to {:?}", url);
let mut req = Request::post(url).body(ping_request.body.clone());
for (&header_key, header_value) in ping_request.headers.iter() {
req = req.header(header_key, header_value)?;