Closed Bug 1143090 Opened 9 years ago Closed 6 years ago

Enable recording Telemetry locally for mochitests and disable its submission

Categories

(Toolkit :: Telemetry, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: overholt, Unassigned)

Details

I am writing a Telemetry probe and would like to be able to verify it is collected properly in a mochitest.  After some headscratching and discussion with Vladan, it appears we don't have Telemetry enabled while running mochitests; it would be nice if we did.
We don't want to submit this telemetry data to the server, though, right?
I was just trying to write a mochitest for verifying telemetry and probably would have been very confused by things not being counted, so this is a timely bug.
(In reply to Mark Reid [:mreid] from comment #1)
> We don't want to submit this telemetry data to the server, though, right?

Correct (IMO).
Summary: Enable Telemetry for mochitests → Enable Telemetry for mochitests and disable only its submission
Summary: Enable Telemetry for mochitests and disable only its submission → Enable recording Telemetry locally for mochitests and disable its submission
Andrew, Vladan asked me to help with this if you have any question. How urgent is that work?
Flags: needinfo?(overholt)
(In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment #4)
> Andrew, Vladan asked me to help with this if you have any question. How
> urgent is that work?

Oh, it's not.  I'll land my probe without a test as it seems that's what's normally done :)  But I'll watch here and add a test when this is ready.  Thanks!
Flags: needinfo?(overholt)
In the meantime, I believe that the following snippet is sufficient:

  let oldCanRecord = Services.telemetry.canRecord;
  Services.telemetry.canRecord = true;
  registerCleanupFunction(() => {
    Services.telemetry.canRecord = oldCanRecord;
  });

That's what I use in my test code that needs to play with Telemetry.
We already disable submission on non-official builds, and mochitests can enable telemetry collection.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.