How To Test New UMA Logging?

887 views
Skip to first unread message

Mark Pearson

unread,
Nov 18, 2011, 3:17:03 PM11/18/11
to chromi...@chromium.org

Hi,

I'd like to record a new action via UMA.  I have the code written.  It'd like to test it end-to-end by running a browser, interacting with it, and seeing if UMA logs contain what I expect.

I can't find any docs or discussion about how to test UMA changes.  Can someone help?

[sent via e-mail so other people who have the same problem can search the archives and get the answer.  Forgive me if this is documented somewhere; I can't find it.]

thanks,
mark

Jói Sigurðsson

unread,
Nov 18, 2011, 3:49:38 PM11/18/11
to mpea...@chromium.org, chromi...@chromium.org, Jim Roskind
Are you sure you need an end-to-end test rather than a unit test to
check that the appropriate histograms have been updated? It seems
like the end-to-end functionality should just be tested for the UMA
mechanism in general rather than for individual stats.

If you want an example of a unit test, see e.g.
URLRequestThrottlerEntryTest::CalculateHistogramDeltas
(http://codesearch.google.com/#OAMlx_jo-ck/src/net/url_request/url_request_throttler_unittest.cc&l=208).

If you really want an end-to-end test, then jar@ is probably the right
person to ask about that.

Cheers,
Jói

> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev

Rachel Weinstein Petterson

unread,
Nov 18, 2011, 3:56:12 PM11/18/11
to j...@chromium.org, mpea...@chromium.org, chromi...@chromium.org, Jim Roskind, Ilya Sherman
Or are you trying to test that your stats are actually being recorded? Ilya has some examples of testing that in autofill_metrics_unittest.cc:  http://www.google.com/codesearch#OAMlx_jo-ck/src/chrome/browser/autofill/autofill_metrics_unittest.cc&exact_package=chromium&q=autofill_metrics_unittest&type=cs 

- Rachel

Jim Roskind

unread,
Nov 18, 2011, 4:11:05 PM11/18/11
to mpea...@chromium.org, chromi...@chromium.org
You used the phrase "record a new action" via UMA.  I'm not sure if you mean a new "Event" or you mean a new "Histogram" or you mean "you've changed the protobufs, and want to do end to end testing before checking into google3, etc. etc.."

The most common question is around histograms.  When you add a histogram, you should visit:

about:histograms

and make sure you data appears on your page as you'd expect.  That should catch 99% of the problems.

YMMV,

Jim

Jim Roskind

unread,
Nov 18, 2011, 5:40:48 PM11/18/11
to mpea...@chromium.org, chromi...@chromium.org
I looked at the CL you were working on.  It attempted to change elements of the internals of UMA that are not generally touched.  You should restrict your CL to using UMA_HISTOGRAM_* and then you'll have a much better time of it.

Jim

Mark Pearson

unread,
Nov 19, 2011, 9:19:24 AM11/19/11
to Jim Roskind, chromi...@chromium.org

Thanks everyone for the examples of unit tests and the tip to look at about:histograms to test UMA histograms.  I'm sure those can handle testing the majority of changes people make to UMA.

Assuming I can't use about:histograms and want to look at the raw XML that UMA's uploading to the feedback servers, is there any way to do that?

thanks,
mark

Jim Roskind

unread,
Nov 19, 2011, 9:56:50 AM11/19/11
to Mark Pearson, chromi...@chromium.org
It used to be the case that you could use the following Chrome command line switches:

--enable-logging --log-level=0

(I *think* those are the settings... YMMV... please verify)

If you do those settings, then the UMA logs will be writen (in human readable(?) XML into the Chrome logs.

Hope that helps,

Jim

Mark Pearson

unread,
Nov 21, 2011, 4:00:39 PM11/21/11
to Jim Roskind, chromi...@chromium.org
On Sat, Nov 19, 2011 at 9:56 AM, Jim Roskind <j...@chromium.org> wrote:
It used to be the case that you could use the following Chrome command line switches:

--enable-logging --log-level=0

(I *think* those are the settings... YMMV... please verify)

If you do those settings, then the UMA logs will be writen (in human readable(?) XML into the Chrome logs.

Thanks.

I built my change on linux and see that Preferences -> Under the Hood -> Automatically send usage statistics and crash reports to Google is not an option.  Obviously, to test UMA changes, I want to turn this on, at least so I can read the UMA logs and see if they're right.  How do I make this option appear?  Anyone know where it's being hidden/disabled?

thanks,
mark

Jim Roskind

unread,
Nov 21, 2011, 5:49:35 PM11/21/11
to Mark Pearson, chromi...@chromium.org
The easiest way to fix this is to edit chrome_browser_main.cc.  I think you need to search for the word "official" and you'll see where we initialize the preference services.  You should hard-wire the initialization to be on, and then you're build will generate logs etc.

Jim
Reply all
Reply to author
Forward
0 new messages