Skip to content

Commit

Permalink
Bug 1851698 - Update default maxEvents to 1
Browse files Browse the repository at this point in the history
changelog
- set the default `maxEvents` number to 1
- update existing tests that rely on having more than 1 event
- update comments in `pings.yaml`
  • Loading branch information
rosahbruno committed Sep 5, 2023
1 parent f4c9b0e commit 8fb3d66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions glean/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Context } from "./context.js";

const LOG_TAG = "core.Config";

// The default maximum number of events Glean will store before submitting the events ping.
// If the maximum is hit, the events ping is sent immediately.
const DEFAULT_MAX_EVENTS = 500;
// By default we want to send the events ping after every event is recorded. Unless the user
// explicitly sets a higher value, we will send the events ping after every event.
const DEFAULT_MAX_EVENTS = 1;

/**
* Lists Glean's debug options.
Expand Down
4 changes: 2 additions & 2 deletions glean/src/pings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ events:
from the previous application run in storage.
It is also sent when maximum capacity is hit
i.e. when a given number of events is in storage.
Maximum capacity defaults to 500,
Maximum capacity defaults to 1,
but may be changed through the `maxEvents` configuration option.
include_client_id: true
bugs:
Expand All @@ -56,7 +56,7 @@ events:
The events ping is always sent if there are any pending events at startup,
because event timestamps are not as reliable across application runs.
max_capacity: |
The maximum number of events was reached (default 500 events).
The maximum number of events was reached (default 1 event).
inactive: |
The ping was submitted when becoming inactive. In earlier versions, this
was called `background`.
Expand Down
6 changes: 5 additions & 1 deletion glean/tests/unit/core/metrics/events_database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ describe("EventsDatabase", function() {
// Restore timer APIs for WaitableUploader to work
clock.restore();

await testResetGlean(testAppId, true, { maxEvents: 500 });

const event = new EventMetricType({
category: "test",
name: "event",
Expand All @@ -780,6 +782,8 @@ describe("EventsDatabase", function() {
// Restore timer APIs for WaitableUploader to work
clock.restore();

await testResetGlean(testAppId, true, { maxEvents: 500 });

const previousRunEvent = new EventMetricType({
category: "test",
name: "previousRun",
Expand Down Expand Up @@ -809,7 +813,7 @@ describe("EventsDatabase", function() {
const httpClient = new WaitableUploader();
const waitForEventsPings = httpClient.waitForBatchPingSubmission(EVENTS_PING_NAME, 2);
// Initialization should trigger a startup ping
await testInitializeGlean(testAppId, true, { httpClient });
await testInitializeGlean(testAppId, true, { httpClient, maxEvents: 500 });
// Send another 'events' ping after init, it should contain the preInit events
await Context.corePings.events.submitUndispatched();

Expand Down

0 comments on commit 8fb3d66

Please sign in to comment.