-
Notifications
You must be signed in to change notification settings - Fork 177
adding best practices for telemetry events design #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
18b4678
adding best practices for telemetry events design
SuYoungHong a0a53fa
updated events best pratice with more background and examples
SuYoungHong 9e22b3e
Update events_best_practices.md
SuYoungHong 224e862
Merge branch 'master' into events-best-practices
SuYoungHong 3dfcafa
Update events_best_practices.md
SuYoungHong fb699c7
Update events_best_practices.md
SuYoungHong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # Telemetry Events Best Practices | ||
|
|
||
| ## Overview: | ||
|
|
||
| [The Telemetry Events API](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html) allows users to define and record events in the browser. | ||
|
|
||
| Events are defined in [`Events.yaml`](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#the-yaml-definition-file) and each events creates records with the following properties: | ||
| * timestamp | ||
| * category | ||
| * method | ||
| * object | ||
| * value | ||
| * extra | ||
|
|
||
| With the following restrictions and features: | ||
| * The category, method, and object properties of any record produced by an event must have a value. | ||
| * All combinations of values from the category, method, and object properties must be unique to that particular event (no other event can produce events with the same combination). | ||
| * Events can be 'turned on' or 'turned off' by it's category value. i.e. we can instruct the browser to "stop sending us events from the `devtools` category." | ||
|
|
||
| These records are then stored in [event pings](http://gecko-docs.mozilla.org.s3.amazonaws.com/toolkit/components/telemetry/telemetry/data/event-ping.html) and available in the [events dataset](https://docs.telemetry.mozilla.org/datasets/batch_view/events/reference.html). | ||
|
|
||
| ## Identifying Events | ||
|
|
||
| One challenge with this data is it can be difficult to identify all the records from a particular event. Unlike Scalars and Histograms, which keep data in individual locations (like `scalar_parent_browser_engagement_total_uri_count` for [`total_uri_count`](https://dxr.mozilla.org/mozilla-central/source/toolkit/components/telemetry/Scalars.yaml#99)), all event records are stored together, regardless of which event generated them. The records themselves don't have a field identifying which event produced it[1]. | ||
|
|
||
| Take, for example, the [`manage`](https://dxr.mozilla.org/mozilla-central/source/toolkit/components/telemetry/Events.yaml#105) | ||
| event in the `addonsManager` category. | ||
|
|
||
| ``` | ||
| addonsManager: # category | ||
| manage: # event name | ||
| description: > | ||
| ... | ||
| objects: ["extension", "theme", "locale", "dictionary", "other"] # object values | ||
| methods: ["disable", "enable", "sideload_prompt", "uninstall"] # method values | ||
| extra_keys: # extra values | ||
| ... | ||
| notification_emails: ... | ||
| expiry_version: ... | ||
| record_in_processes: ... | ||
| bug_numbers: ... | ||
| release_channel_collection: ... | ||
| ``` | ||
| This event will produce records that look like: | ||
|
|
||
| |timestamp| category | method | object | value | extra | | ||
| |-| -------- |---------| --------|-------|-------| | ||
| |...|`addonsManager`|`install`|`extension`| |...| | ||
| |...|`addonsManager`|`update`|`locale`| |...| | ||
| |...|`addonsManager`|`sideload_prompt`|`other`| |...| | ||
|
|
||
| But none of these records will indicate that it was produced by the `manage` event. To find all records produced by `manage`, one would have to query all records where | ||
| ``` | ||
| category = ... | ||
| AND method in [...,] | ||
| AND object in [...,] | ||
| ``` | ||
| which is not ideal. | ||
|
|
||
| Furthermore, if one encounters this data without knowledge of how the `manage` event works, they need to look up the event based on the category, method, and object values in order to find the event, and then query the data again to find all the related events. It's not immediately clear from the data if this record: | ||
|
|
||
| |timestamp| category | method | object | value | extra | | ||
| |-| -------- |---------| --------|-------|-------| | ||
| |...|`addonsManager`|`update`|`locale`| |...| | ||
|
|
||
| and and this record: | ||
|
|
||
| |timestamp| category | method | object | value | extra | | ||
| |-| -------- |---------| --------|-------|-------| | ||
| |...|`addonsManager`|`install`|`extension`| |...| | ||
|
|
||
| are related or not. | ||
|
|
||
| Another factor that can add to confusion is the fact that other events can share similar values for methods or objects (or even the combination of method and object). For example: | ||
|
|
||
| |timestamp| category | method | object | value | extra | | ||
| |-| -------- |---------| --------|-------|-------| | ||
| |...|`normandy`|`update`|`preference_rollout`| |...| | ||
|
|
||
| which can further confuser users. | ||
|
|
||
| [1]: Events do have name fields, but they aren't included in the event records and thus are not present in the resulting dataset. Also, If a user defines an event in `Events.yaml` without specifying a list of acceptable methods, the method will default to the name of the event for records created by that event. | ||
|
|
||
| #### Suggested Convention: | ||
|
|
||
| To simplify things in the future, we suggest adding the event name to the category field using dot notation when designing new events: | ||
|
|
||
| ``` | ||
| "category.event_name" | ||
| ``` | ||
|
|
||
| For example: | ||
| * ```"navigation.search"``` | ||
| * ```"addonsManager.manage"``` | ||
| * ```"frame.tab"``` | ||
|
|
||
|
|
||
| This provides 3 advantages: | ||
| 1. Records produced by this event will be easily identifiable. Also, the event which produced the record will be easier to locate in the code. | ||
| 2. Events can be controlled more easily. The category field is what we use to "turn on" and "turn off" events. By creating a 1 to 1 mapping between categories and events, we can control events on an individual level. | ||
| 3. By having the category field act as the event identifier, it makes it easier to pass on events to Amplitude and other platforms. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand the example? Maybe take the opportunity to show how the
addonsManager.manageexample definition above would be changed by this convention.