{"id":26,"date":"2017-09-18T11:27:56","date_gmt":"2017-09-18T11:27:56","guid":{"rendered":"https:\/\/blog.mozilla.org\/data\/?p=26"},"modified":"2019-10-17T20:21:00","modified_gmt":"2019-10-17T20:21:00","slug":"recording-new-telemetry-from-add-ons","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/data\/2017\/09\/18\/recording-new-telemetry-from-add-ons\/","title":{"rendered":"Recording new Telemetry from add-ons"},"content":{"rendered":"<p>One of the successes for Firefox Telemetry has been the introduction of standardized data types; <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/histograms.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/histograms.html\">histograms<\/a> and <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/scalars.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/scalars.html\">scalars<\/a>.<\/p>\n<p>They are well defined and allow teams to autonomously add new instrumentation. As they are listed in machine-readable files, our data pipeline can support them automatically and new probes just start showing up in different tools. A definition <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/dxr.mozilla.org\/mozilla-central\/rev\/93dd2e456c0ecca00fb4d28744e88078a77deaf7\/toolkit\/components\/telemetry\/Scalars.yaml#38\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/dxr.mozilla.org\/mozilla-central\/rev\/93dd2e456c0ecca00fb4d28744e88078a77deaf7\/toolkit\/components\/telemetry\/Scalars.yaml#38\">like this<\/a> enables views like <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/mzl.la\/2ePaBPK\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/mzl.la\/2ePaBPK\">this<\/a>:<\/p>\n<div id=\"attachment_27\" style=\"width: 610px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-27\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-27 size-large\" src=\"http:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-21.48.52-fixed-600x256.png\" alt=\"The distribution view for the max_concurrent_tabs scalar on the TMO dashboard.\" width=\"600\" height=\"256\" srcset=\"https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-21.48.52-fixed-600x256.png 600w, https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-21.48.52-fixed-250x107.png 250w, https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-21.48.52-fixed-768x328.png 768w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><p id=\"caption-attachment-27\" class=\"wp-caption-text\">The distribution view for the max_concurrent_tabs scalar on the TMO dashboard.<\/p><\/div>\n<p>This works great when shipping probes in the Firefox core code, going through our normal release and testing channels, which takes a few weeks.<\/p>\n<h3 id=\"e18d\" class=\"graf graf--h3 graf-after--p\">Going faster<\/h3>\n<p id=\"bbd3\" class=\"graf graf--p graf-after--h3\">However, often we want to <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/wiki.mozilla.org\/Firefox\/Go_Faster\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/wiki.mozilla.org\/Firefox\/Go_Faster\">ship code faster<\/a> using add-ons: this may mean running experiments through Test Pilot and SHIELD or deploying Firefox features through system add-ons.<\/p>\n<p id=\"6faa\" class=\"graf graf--p graf-after--p\">When adding new instrumentation in add-ons, there are two options:<\/p>\n<ul class=\"postList\">\n<li id=\"0ee3\" class=\"graf graf--li graf-after--p\">Instrumenting the code in Firefox core code, then waiting a few weeks until it is in release.<\/li>\n<li id=\"34e6\" class=\"graf graf--li graf-after--li\">Implementing a <a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/custom-pings.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/custom-pings.html\">custom ping<\/a> and submitting it through Telemetry, requiring additional client and pipeline work.<\/li>\n<\/ul>\n<p id=\"3193\" class=\"graf graf--p graf-after--li\">Neither are satisfactory; there is significant manual effort for running simple experiments and adding features.<\/p>\n<h3 id=\"5610\" class=\"graf graf--h3 graf-after--p\">Filling the\u00a0gap<\/h3>\n<p id=\"7217\" class=\"graf graf--p graf-after--h3\">This is one of the main pain-points coming up for adding new data collection, so over the last months we were planning how to solve this.<\/p>\n<p id=\"0fd8\" class=\"graf graf--p graf-after--p\">As the scope of an end-to-end solution is rather large, we are currently focused on getting the support built into Firefox first. This can enable some use-cases right away. We can then later add better and automated integration in our data pipeline and tooling.<\/p>\n<p id=\"97ca\" class=\"graf graf--p graf-after--p\">The basic idea is to use the existing Telemetry APIs and seamlessly allow them to record data from new probes as well. To enable this, we will extend the API with registration of new probes from add-ons at runtime.<\/p>\n<p id=\"0b4d\" class=\"graf graf--p graf-after--p\">The recorded data will be submitted with the main ping, but in a separate bucket to tell them apart.<\/p>\n<h3 id=\"a3a0\" class=\"graf graf--h3 graf-after--p\">What we have\u00a0now<\/h3>\n<p id=\"b561\" class=\"graf graf--p graf-after--h3\">We now support <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/events.html#registerevents\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/events.html#registerevents\">add-on registration of events<\/a> from Firefox 56 on. We expect event recording to mostly be used with experiments, so it made sense to start here.<\/p>\n<p id=\"e99c\" class=\"graf graf--p graf-after--p\">With this new addition, events can be registered at runtime by Mozilla add-ons instead of using a registry file like <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/dxr.mozilla.org\/mozilla-central\/source\/toolkit\/components\/telemetry\/Events.yaml\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/dxr.mozilla.org\/mozilla-central\/source\/toolkit\/components\/telemetry\/Events.yaml\"><em class=\"markup--em markup--p-em\">Events.yaml<\/em><\/a>.<\/p>\n<p id=\"c888\" class=\"graf graf--p graf-after--p\">When starting, add-ons call <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/events.html#registerevents\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/collection\/events.html#registerevents\"><em class=\"markup--em markup--p-em\">nsITelemetry.registerEvents()<\/em><\/a> with information on the events they want to record:<\/p>\n<pre id=\"b6c4\" class=\"graf graf--pre graf-after--p\">Services.telemetry.registerEvents(\u201cmyAddon.ui\u201d, {\r\n  \u201cclick\u201d: {\r\n    methods: [\u201cclick\u201d],\r\n    objects: [\u201credButton\u201d, \u201cblueButton\u201d],\r\n  }\r\n});<\/pre>\n<p id=\"528d\" class=\"graf graf--p graf-after--pre\">Now, events can be recorded using the normal Telemetry API:<\/p>\n<pre id=\"c3b1\" class=\"graf graf--pre graf-after--p\">Services.telemetry.recordEvent(\u201cmyAddon.ui\u201d, \u201cclick\u201d,\r\n                               \u201credButton\u201d);<\/pre>\n<p>This event will be submitted with the next main ping in the \u201cdynamic\u201d process section. We can inspect them through <em class=\"markup--em markup--p-em\">about:telemetry<\/em>:<\/p>\n<div id=\"attachment_28\" style=\"width: 610px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-28\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-28 size-large\" src=\"http:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-20.45.34-600x134.png\" alt=\"The event view in about:telemetry, showing that an event [&quot;myAddon.ui&quot;, &quot;click&quot;, &quot;redButton&quot;] was successfully recorded with a timestamp.\" width=\"600\" height=\"134\" srcset=\"https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-20.45.34-600x134.png 600w, https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-20.45.34-250x56.png 250w, https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-20.45.34-768x172.png 768w, https:\/\/blog.mozilla.org\/data\/files\/2017\/09\/Screen-Shot-2017-09-07-at-20.45.34.png 1590w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><p id=\"caption-attachment-28\" class=\"wp-caption-text\">The event view in about:telemetry.<\/p><\/div>\n<p id=\"f180\" class=\"graf graf--p graf-after--figure\">On the pipeline side, the events are available in the <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/docs.telemetry.mozilla.org\/datasets\/batch_view\/events\/reference.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/docs.telemetry.mozilla.org\/datasets\/batch_view\/events\/reference.html\"><em class=\"markup--em markup--p-em\">events<\/em> table<\/a> in Redash. Custom analysis can access them in the <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/data\/main-ping.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/firefox-source-docs.mozilla.org\/toolkit\/components\/telemetry\/telemetry\/data\/main-ping.html\"><em class=\"markup--em markup--p-em\">main<\/em><\/a> pings under <em class=\"markup--em markup--p-em\">payload\/processes\/dynamic\/events<\/em>.<\/p>\n<h3 id=\"d381\" class=\"graf graf--h3 graf-after--p\">The larger\u00a0plan<\/h3>\n<p id=\"b471\" class=\"graf graf--p graf-after--h3\">As mentioned, this is the first step of a larger project that consists of multiple high-level pieces. Not all of them are feasible in the short-term, so we intend to work towards them iteratively.<\/p>\n<p id=\"06c7\" class=\"graf graf--p graf-after--p\">The main driving goals here are:<\/p>\n<ol class=\"postList\">\n<li id=\"a0c1\" class=\"graf graf--li graf-after--p\">Make it easy to submit new Telemetry probes from Mozilla add-ons.<\/li>\n<li id=\"042e\" class=\"graf graf--li graf-after--li\">New Telemetry probes from add-ons are easily accessible, with minimal manual work.<\/li>\n<li id=\"5c40\" class=\"graf graf--li graf-after--li\">Uphold our standards for data quality and data review.<\/li>\n<li id=\"ee61\" class=\"graf graf--li graf-after--li\">Add-on probes should be discoverable from one central place.<\/li>\n<\/ol>\n<p id=\"0a69\" class=\"graf graf--p graf-after--li\">This larger project then breaks down into roughly these main pieces:<\/p>\n<p id=\"1f57\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">Phase 1: Client work.<\/strong><\/p>\n<p id=\"b26a\" class=\"graf graf--p graf-after--p\">This is currently happening in Q3 &amp; Q4 2017. We are focusing on adding &amp; extending Firefox Telemetry APIs to register &amp; record new probes.<\/p>\n<p id=\"a9e5\" class=\"graf graf--p graf-after--p\">Events are supported in Firefox 56, scalars will follow in 57 or 58, then histograms on a later train. The add-on probe data is sent out with the main ping.<\/p>\n<p id=\"782c\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">Phase 2: Add-on tooling work.<\/strong><\/p>\n<p id=\"5ee2\" class=\"graf graf--p graf-after--p\">To enable pipeline automation and data documentation, we want to define a variant of the standard registry formats (like <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/dxr.mozilla.org\/mozilla-central\/source\/toolkit\/components\/telemetry\/Scalars.yaml\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/dxr.mozilla.org\/mozilla-central\/source\/toolkit\/components\/telemetry\/Scalars.yaml\"><em class=\"markup--em markup--p-em\">Scalars.yaml<\/em><\/a>). By providing utilities we can make it easier for add-on authors to integrate them.<\/p>\n<p id=\"eafc\" class=\"graf graf--p graf-after--p\"><strong class=\"markup--strong markup--p-strong\">Phase 3: Pipeline work.<\/strong><\/p>\n<p id=\"1817\" class=\"graf graf--p graf-after--p\">We want to pull the probe registry information from add-ons together in one place, then make it available publically. This will enable automation of data jobs, data discovery and other use-cases. From there we can work on integrating this data into our main datasets and tools.<\/p>\n<p id=\"5920\" class=\"graf graf--p graf-after--p\">The later phases are not set in stone yet, so please reach out if you see gaps or overlap with other projects.<\/p>\n<h3 id=\"c97a\" class=\"graf graf--h3 graf-after--p\">Questions?<\/h3>\n<p id=\"4542\" class=\"graf graf--p graf-after--h3\">As always, if you want to reach out or have questions:<\/p>\n<ul class=\"postList\">\n<li id=\"b9f6\" class=\"graf graf--li graf-after--p\">You can find us on IRC in <em class=\"markup--em markup--li-em\">#telemetry<\/em> and <em class=\"markup--em markup--li-em\">#datapipeline<\/em>.<\/li>\n<li id=\"2c87\" class=\"graf graf--li graf-after--li\">We are available on slack in <em class=\"markup--em markup--li-em\">#fx-metrics<\/em>.<\/li>\n<li id=\"ef1c\" class=\"graf graf--li graf-after--li\">The main mailing list for data topics is<a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/mail.mozilla.org\/listinfo\/fx-data-dev\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/mail.mozilla.org\/listinfo\/fx-data-dev\"> fx-data-dev<\/a>.<\/li>\n<li id=\"8d8d\" class=\"graf graf--li graf-after--li\">Bugs can be filed in<a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/wiki.mozilla.org\/Telemetry#Filing_Bugs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/wiki.mozilla.org\/Telemetry#Filing_Bugs\"> one of these components<\/a>.<\/li>\n<li id=\"d38f\" class=\"graf graf--li graf-after--li graf--trailing\">You can also find us on Twitter as<a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/twitter.com\/moztelemetry\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" data-href=\"https:\/\/twitter.com\/moztelemetry\"> @MozTelemetry<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>One of the successes for Firefox Telemetry has been the introduction of standardized data types; histograms and scalars. They are well defined and allow teams to autonomously add new instrumentation. &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/data\/2017\/09\/18\/recording-new-telemetry-from-add-ons\/\">Read more<\/a><\/p>\n","protected":false},"author":1517,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[315988],"tags":[5868,525,39,3969],"coauthors":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/users\/1517"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/tags?post=26"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mozilla.org\/data\/wp-json\/wp\/v2\/coauthors?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}