Closed Bug 1685402 Opened 4 years ago Closed 4 years ago

Support Custom Ping Unit Tests in FOG's JS and C++ languages

Categories

(Toolkit :: Telemetry, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: chutten, Assigned: chutten)

References

(Blocks 1 open bug)

Details

(Whiteboard: [telemetry:fog:m?])

Attachments

(2 files)

Following the design in bug 1681742 (proposal doc), implement a mechanism to unit test custom pings in C++ and JS.

Don't forget tests (GTests and xpcshell) and documentation (in the Glean Book). Due to the (likely) language-specific nature of the API, I don't expect this to have to block on work in bug 1685401, but we should coordinate so that any changes to the design are reflected equivalently across the languages.

Assignee: nobody → chutten
Blocks: 1670259
Status: NEW → ASSIGNED
Priority: P3 → P1

I hear from Mossop that a way to do this would be the way nsITimer does with nsITimerCallback: apply the function annotation to the functor so that the JS API can take a function directly.

Then in C++ we could take std::function<void(const nsACString& aReason)> const& so we could take lambda expressions.

The idea'd be, for JS:

GleanPings.myPing.testBeforeNextSubmit((reason) => { /* ... */ });

C++:

mozilla::glean_pings::MyPing.TestBeforeNextSubmit([](const nsACString& aReason) { /* ... */ });

Two notes:

  1. To make builds faster and hide the callback map, I've pulled the C++ impl
    into Ping.cpp.
    Doing this for the rest of the metrics is bug 1705394.
  2. Doesn't wait on the queue to drain, actually writing metric values.
    This means that the callback may be running before values reach the db.
    This is surprisingly okay! Because the only way to check metrics values is
    testGetValue which, you guessed it, waits on the queue to drain.

Depends on D112219

Pushed by chutten@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/00dc350a9371 FOG Rust testBeforeNextSubmit r=janerik https://hg.mozilla.org/integration/autoland/rev/f9eb32e83608 FOG JS and C++ TestBeforeNextSubmit r=janerik

Oh, I didn't ifdef out an unused function in the android build (GetCallbackMapLock). Easy enough to fix. I really do wish I could compile with warnings-as-errors locally, but there's way too much GTK nonsense for that ever to clear up.

Not sure quite what went wrong with the backout that caught bug 1704846 in the mix, but I'll see what I can do to land these both more sedately this time.

Flags: needinfo?(chutten)
Pushed by chutten@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/76ae5fc0cc74 FOG Rust testBeforeNextSubmit r=janerik https://hg.mozilla.org/integration/autoland/rev/a0e7ceed0a81 FOG JS and C++ TestBeforeNextSubmit r=janerik
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: