Skip to content

Comments

adding best practices for telemetry events design#197

Merged
chutten merged 6 commits intomozilla:masterfrom
SuYoungHong:events-best-practices
Feb 13, 2019
Merged

adding best practices for telemetry events design#197
chutten merged 6 commits intomozilla:masterfrom
SuYoungHong:events-best-practices

Conversation

@SuYoungHong
Copy link
Contributor

Added cookbook for telemetry events design best practices. RE this bug

Not sure where in the docs this should live, so put it into cookbooks by default.

@SuYoungHong SuYoungHong requested a review from chutten October 23, 2018 03:40
Copy link
Contributor

@chutten chutten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't clear from the document the problem we're trying to solve with this. I recommend providing an example (perhaps one from your own experience) showing the difficulty in finding the definition and code when all you have are rows from the events dataset or user flows in Amplitude.

For instance, trying to nail down where devtools.main.open comes from in the code is tricky. This is because each of the category, method, and object are too common in the code base and in Firefox data collections.

src/SUMMARY.md Outdated
* [Metrics](cookbooks/metrics.md)
* [Active DAU Definition](cookbooks/active_dau.md)
* [Retention Analysis](cookbooks/retention.md)
* [Designing Telemetry Events Best Practices](cookbooks/designing_events_best_practices.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could drop "Designing" here and gain brevity without losing meaning.


## Naming Events/Probes:

One of the limitations of the Telemetry Events API is that it is difficult to distinguish between events produced by different probes. The API allows for a lot of flexibility. Any probe written into Firefox can create an event with any values the following fields:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording here I think should be "can record an event" or "can create an event record".

Also, somewhere around here you can link out to this part of the docs for the technical docs.

* The Category, Method, and Object of any event produced by the probe must have a value.
* All combinations of Category, Method, and Object values must be unqiue to that probe (no other probes can produce the same combination).

However, there is no identifier or name field for the probe itself. Furthermore, although the combinations of Category, Method, and Object for a probe must be unique, individually, those fields can share values with other probes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid calling attention to the "name field" as there is indeed an event name field: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#the-yaml-definition-file

You can instead contrast this to Histograms and Scalars whose definitions each have a unique identifier: their metric name.


However, there is no identifier or name field for the probe itself. Furthermore, although the combinations of Category, Method, and Object for a probe must be unique, individually, those fields can share values with other probes.

This can make it confusing and difficult to isolate events from a particular probe, or find what probe produced a specific event.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of the word "probe" is unclear here. What is meant by it?

@SuYoungHong
Copy link
Contributor Author

@chutten , good points. I've updated the cookbook to provide more background and give some more concrete examples to make the need more clear. Let me know what you think.

Copy link
Contributor

@chutten chutten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for leaving this for so long.


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 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* All combinations 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).
* All combinations of values from the category, method, and object properties must be unique to that particular event (no other event can be registered with the same combination).

* All combinations 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 'devtools' category."

These records are then stored in event pings and available in the events dataset.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend linking out to the event pipeline and dataset docs here.


which can further confuser users.

[1]: 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to preface this footnote with "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..."

"category.event_name"
```

For example:
Copy link
Contributor

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.manage example definition above would be changed by this convention.



This provides 3 advantages:
1. Records produced by this event will be easily identifiable. Conversely, the event which produced the record will be easier to locate in the code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Conversely" is usually reserved for statements that oppose the previous one. I'd go with "Also" here.


This provides 3 advantages:
1. Records produced by this event will be easily identifiable. Conversely, the event which produced the record will be easier to locate in the code.
2. Events can be controlled easier. 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Events can be controlled easier. 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.
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.

@georgf
Copy link
Contributor

georgf commented Feb 13, 2019

@SuYoungHong @chutten
Hey, this looks great. Could i do anything to help unblocking this from merging?

Future improvements aside, are there any blocking changes needed here? Could the rest be moved to follow-ups?

@SuYoungHong
Copy link
Contributor Author

hey @georgf , @chutten , apologies for the long delay.
I've made some of the suggested changes to the document. I think this is ready to merge, and we can resolve the following issue:

  • clarifying example for suggested convention using addonsManager.manage

In the future with a separate PR

@SuYoungHong
Copy link
Contributor Author

looks like it's also running into issues with travis.

It's failing tests based on spelling for the following words (filenames and event field values):

  • Events.yaml
  • devtools
  • total_uri_count
  • addonsManager
  • sideload_prompt
  • normandy
  • preference_rollout

how do you advise I resolve these? should I treat event field values as code in blocks? also for filenames?

@chutten
Copy link
Contributor

chutten commented Feb 13, 2019

Code blocks might be the most sensible way. The alternative is to add it to the list of exceptions in .spelling

@ethompso28
Copy link
Contributor

@SuYoungHong : I got a fantastic tip from @tdsmith to install the mdspell, so that you can run it locally before submitting the PR and fix all the spelling errors before it goes through CI:

npm install markdown-spellcheck markdown-link-check -g
then
mdspell 'src/**/*.md' --ignore-numbers --en-us --report

fixed spelling nits (into code) for travis tests
@SuYoungHong
Copy link
Contributor Author

thanks @ethompso28 ! I'll check it out!

@SuYoungHong
Copy link
Contributor Author

cool, tests pass now. PR ready to merge if @chutten is okay with pushing the final change request to another PR (if not, let me know and I can make the change in this PR)

  • Su

@chutten chutten merged commit b2f8577 into mozilla:master Feb 13, 2019
@chutten
Copy link
Contributor

chutten commented Feb 13, 2019

I'm fine with it happening as a follow-up. Thanks for your persistence in this!

@SuYoungHong SuYoungHong deleted the events-best-practices branch February 13, 2019 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants