зеркало из https://github.com/mozilla/glean.git
Bug 1661240 - Have same throttle backoff time for all bindings (#1240)
This commit is contained in:
Родитель
6e82e85417
Коммит
2261845761
|
@ -3,6 +3,7 @@
|
|||
[Full changelog](https://github.com/mozilla/glean/compare/v33.0.4...main)
|
||||
|
||||
* General
|
||||
* Standardize throttle backoff time throughout all bindings. ([#1240](https://github.com/mozilla/glean/pull/1240))
|
||||
* Update `glean_parser` to 1.29.0
|
||||
* Generated code now includes a comment next to each metric containing the name of the metric in its original `snake_case` form.
|
||||
* Android
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Mozilla.Glean.Net
|
|||
/// </summary>
|
||||
internal class BaseUploader
|
||||
{
|
||||
internal const int THROTTLED_BACKOFF_MS = 60_000;
|
||||
private readonly IPingUploader uploader;
|
||||
|
||||
/// <summary>
|
||||
|
@ -88,8 +89,6 @@ namespace Mozilla.Glean.Net
|
|||
// TODO: must not work like this, it should work off the main thread.
|
||||
// FOR TESTING Implement the upload worker here and call this from Glean.cs
|
||||
|
||||
int waitAttempts = 0;
|
||||
|
||||
// Limits are enforced by glean-core to avoid an inifinite loop here.
|
||||
// Whenever a limit is reached, this binding will receive `UploadTaskTag.Done` and step out.
|
||||
while (true)
|
||||
|
@ -126,7 +125,7 @@ namespace Mozilla.Glean.Net
|
|||
}
|
||||
break;
|
||||
case UploadTaskTag.Wait:
|
||||
Thread.Sleep(100);
|
||||
Thread.Sleep(THROTTLED_BACKOFF_MS);
|
||||
break;
|
||||
case UploadTaskTag.Done:
|
||||
// Nothing to do here, break out of the loop.
|
||||
|
|
|
@ -13,6 +13,7 @@ public class HttpPingUploader {
|
|||
// Since ping file names are UUIDs, this matches UUIDs for filtering purposes
|
||||
static let logTag = "glean/HttpPingUploader"
|
||||
static let connectionTimeout = 10000
|
||||
static let throttleBackoffMs: UInt32 = 60_000
|
||||
|
||||
// For this error, the ping will be retried later
|
||||
static let recoverableErrorStatusCode: UInt16 = 500
|
||||
|
@ -117,6 +118,7 @@ public class HttpPingUploader {
|
|||
glean_process_ping_upload_response(&incomingTask, result.toFfi())
|
||||
}
|
||||
case .wait:
|
||||
sleep(Constants.throttleBackoffMs)
|
||||
continue
|
||||
case .done:
|
||||
return
|
||||
|
|
|
@ -230,6 +230,9 @@ class Glean:
|
|||
The temporary directory will be destroyed when Glean is initialized
|
||||
again or at process shutdown.
|
||||
"""
|
||||
# Lower throttle backoff time for testing
|
||||
PingUploadWorker._throttle_backoff_time = 1
|
||||
|
||||
actual_data_dir = Path(tempfile.TemporaryDirectory().name)
|
||||
cls.initialize(
|
||||
application_id,
|
||||
|
|
|
@ -23,6 +23,8 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class PingUploadWorker:
|
||||
_throttle_backoff_time = 60_000
|
||||
|
||||
@classmethod
|
||||
def process(cls):
|
||||
"""
|
||||
|
@ -43,7 +45,13 @@ class PingUploadWorker:
|
|||
from .. import Glean
|
||||
|
||||
return ProcessDispatcher.dispatch(
|
||||
_process, (Glean._data_dir, Glean._application_id, Glean._configuration)
|
||||
_process,
|
||||
(
|
||||
Glean._data_dir,
|
||||
Glean._application_id,
|
||||
Glean._configuration,
|
||||
cls._throttle_backoff_time,
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -94,7 +102,9 @@ def _parse_ping_headers(
|
|||
return headers
|
||||
|
||||
|
||||
def _process(data_dir: Path, application_id: str, configuration) -> bool:
|
||||
def _process(
|
||||
data_dir: Path, application_id: str, configuration, throttle_backoff_time: int
|
||||
) -> bool:
|
||||
|
||||
# Import here to avoid cyclical import
|
||||
from ..glean import Glean
|
||||
|
@ -144,7 +154,7 @@ def _process(data_dir: Path, application_id: str, configuration) -> bool:
|
|||
incoming_task, upload_result.to_ffi()
|
||||
)
|
||||
elif tag == UploadTaskTag.WAIT:
|
||||
time.sleep(1)
|
||||
time.sleep(throttle_backoff_time)
|
||||
elif tag == UploadTaskTag.DONE:
|
||||
return True
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ from glean.metrics import (
|
|||
from glean.net import PingUploadWorker
|
||||
from glean.testing import _RecordingUploader
|
||||
|
||||
|
||||
GLEAN_APP_ID = "glean-python-test"
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче