Closed Bug 1422035 Opened 7 years ago Closed 6 years ago

TelemetryEvent should assert if registerEvent is used in child processes

Categories

(Toolkit :: Telemetry, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: Dexter, Assigned: rohan17089, Mentored)

References

Details

(Whiteboard: [lang=C++][good-first-bug])

Attachments

(1 file, 2 obsolete files)

registerScalars [1] can only be used in the parent process, however registerEvents [2] doesn't seem to enforce the same behaviour and, when used outside of the parent process, event recording won't work.

We should add an assertion to make this explicit.

[1] - https://searchfox.org/mozilla-central/rev/be78e6ea9b10b1f5b2b3b013f01d86e1062abb2b/toolkit/components/telemetry/TelemetryScalar.cpp#2338
[2] - https://searchfox.org/mozilla-central/rev/be78e6ea9b10b1f5b2b3b013f01d86e1062abb2b/toolkit/components/telemetry/TelemetryEvent.cpp#947
Blocks: 1302663
Priority: -- → P2
Mentor: alessio.placitelli
Whiteboard: [lang=C++][good-first-bug]
Rohan, would you be interested in taking this one?
Flags: needinfo?(rohan17089)
Yeah sure,i'll take this
Flags: needinfo?(rohan17089)
Assignee: nobody → rohan17089
So what i can understand is to add an assert statement to explicitly tell that registerevents also has to be used in parent process only,right?
(In reply to Rohan Rajpal from comment #3)
> So what i can understand is to add an assert statement to explicitly tell
> that registerevents also has to be used in parent process only,right?

Yes, you can find an example of that in the code for the scalars in comment 0.
Means i have to add the statement :
MOZ_ASSERT(XRE_IsParentProcess(),
             "Dynamic scalars should only be created in the parent process.");

To registerevents as well,right?
(In reply to Rohan Rajpal from comment #5)
> Means i have to add the statement :
> MOZ_ASSERT(XRE_IsParentProcess(),
>              "Dynamic scalars should only be created in the parent
> process.");
> 
> To registerevents as well,right?

Did the same,building now.Do let me know how to test the build to check for this issue.
Thanks
(In reply to Rohan Rajpal from comment #5)
> Means i have to add the statement :
> MOZ_ASSERT(XRE_IsParentProcess(),
>              "Dynamic scalars should only be created in the parent
> process.");
> 
> To registerevents as well,right?

Yes. You can test that with:

> ./mach gtest Telemetry*
> ./mach test toolkit/components/telemetry
A successfull build 
here are the logs for the two commands you gave to test with:
> ./mach gtest Telemetry*
https://pastebin.com/EaTRj7tV

> ./mach test toolkit/components/telemetry
https://pastebin.com/DAw8zrS9 (got an error here)

I've given the last few lines of the second command as it's way too big
Here is the part before that as well
https://pastebin.com/tatAXXbc

Sorry for the late reply ran into a few things
(In reply to Rohan Rajpal from comment #8)
> A successfull build 
> here are the logs for the two commands you gave to test with:
> > ./mach gtest Telemetry*
> https://pastebin.com/EaTRj7tV
> 
> > ./mach test toolkit/components/telemetry
> https://pastebin.com/DAw8zrS9 (got an error here)
> 
> I've given the last few lines of the second command as it's way too big
> Here is the part before that as well
> https://pastebin.com/tatAXXbc
> 
> Sorry for the late reply ran into a few things

Looks like all the tests are passing: there's a weird Python error that looks unrelated though, so I think we can move on. Would you mind attaching the patch and flag me for review on it?
Flags: needinfo?(alessio.placitelli)
Flags: needinfo?(alessio.placitelli) → needinfo?(rohan17089)
Alright i will,on it.
Flags: needinfo?(rohan17089)
File is located at
mozilla-central/toolkit/components/telemetry/TelemetryEvent.cpp
Attachment #8939588 - Flags: review?(alessio.placitelli)
(In reply to Rohan Rajpal from comment #11)
> Created attachment 8939588 [details] [diff] [review]
> This was the file that had to be edited to add an assert statement.
> 
> File is located at
> mozilla-central/toolkit/components/telemetry/TelemetryEvent.cpp

Hi Rohan!

Your changes need to be submitted as a patch or as a MozReview request. You can have a look at this page [1] to understand how to generate a patch and attach it to this bug! Once the patch is attached, please flag me for review on it ;)

[1] - https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch#Creating_a_patch
Flags: needinfo?(rohan17089)
Attachment #8939588 - Flags: review?(alessio.placitelli)
Ohh my bad,on it.
Flags: needinfo?(rohan17089)
Priority: P2 → P1
If the bug is fixed, can you assign me another one?
Flags: needinfo?(alessio.placitelli)
Comment on attachment 8940275 [details]
Bug 1422035 - Make RegisterEvents assert on children processes.

https://reviewboard.mozilla.org/r/210572/#review216570

Thank you for your patch! In order to land this, we need to make some changes to the code. I've highlighted them below.

::: commit-message-e3048:1
(Diff revision 1)
> +Fixing bug 1422035

Please fix the commit message: it should describe what was done in the patch. See [this guide](https://developer.mozilla.org/en-US/docs/Mercurial/Using_Mercurial#Commit_Message_Conventions) for the commit message conventions.

::: my-change.patch:1
(Diff revision 1)
> +# HG changeset patch

I think this "my-change.patch" file was mistakenly added to the review request. Let's drop it.

::: toolkit/components/telemetry/TelemetryEvent.cpp:948
(Diff revision 1)
>  TelemetryEvent::RegisterEvents(const nsACString& aCategory,
>                                 JS::Handle<JS::Value> aEventData,
>                                 JSContext* cx)
>  {
> +  MOZ_ASSERT(XRE_IsParentProcess(),
> +             "Dynamic scalars should only be created in the parent process.");

Can you change the assertion message to something like: "Events can only be registered in the parent process"?
Attachment #8940275 - Flags: review?(alessio.placitelli) → review-
Comment on attachment 8939588 [details] [diff] [review]
This was the file that had to be edited to add an assert statement.

(In reply to Rohan Rajpal from comment #15)
> If the bug is fixed, can you assign me another one?

I'm afraid the bug is not fixed yet :) The state of the bug will be changed to "RESOLVED FIXED" once it lands on mozilla-central. Before moving on to another bug, we should at least make sure it's landing without problems after the review is complete.
Attachment #8939588 - Attachment is obsolete: true
Flags: needinfo?(alessio.placitelli)
Attachment #8940275 - Attachment is obsolete: true
Attachment #8940275 - Attachment is obsolete: false
Comment on attachment 8941129 [details]
Bug 1422035 - Added assert statement to TelemetryEvent.cpp by addiding asseertions on line 947.

https://reviewboard.mozilla.org/r/211404/#review217426

::: commit-message-1f87d:1
(Diff revision 1)
> +Bug 1422035 - Added assert statement to TelemetryEvent.cpp by addiding asseertions on line 947.r=Dexter

Let's not get too detailed about the implementation here. In general, the first line of a commit message should briefly explain what was done, high level. A good commit message in this case would be "Bug 1422035 - Make RegisterEvents assert on children processes. r?dexter"

::: toolkit/components/telemetry/TelemetryEvent.cpp:948
(Diff revision 1)
>  TelemetryEvent::RegisterEvents(const nsACString& aCategory,
>                                 JS::Handle<JS::Value> aEventData,
>                                 JSContext* cx)
>  {
>    MOZ_ASSERT(XRE_IsParentProcess(),
> -             "Dynamic scalars should only be created in the parent process.");
> +             "Events can only be registered in the parent process");

This changeset doesn't apply cleanly to mozilla-central: it requires your other patch. Please change this so that it applies cleanly to mozilla-central.

To do so you should probably edit your local commit history with `hg histedit`, drop this change and change your previous commit to address the requested feedback.
Attachment #8941129 - Flags: review?(alessio.placitelli) → review-
Attachment #8941129 - Attachment is obsolete: true
Done with the necessary, let me know if anything else is wrong.
Comment on attachment 8940275 [details]
Bug 1422035 - Make RegisterEvents assert on children processes.

https://reviewboard.mozilla.org/r/210572/#review218094

This looks good now, thanks!
Attachment #8940275 - Flags: review?(alessio.placitelli) → review+
Pushed by alessio.placitelli@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/686aaeae4c92
Make RegisterEvents assert on children processes. r=Dexter
Alright then, new bug suggestion?
https://hg.mozilla.org/mozilla-central/rev/686aaeae4c92
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: