platform_system_core/metrics
Bertrand SIMONNET 4764f52d9c metrics: Migrate libchromeos to its own ebuild
All platform2 packages should have their own ebuild that will be compiled
independently. Packages should DEPEND on libchromeos and should not have a gyp
dependency on libchromeos's gyp file anymore.

BUG=chromium:381372
TEST=emerge-daisy libchromeos && emerge-daisy platform2 work
TEST=trybot run on daisy, link, mario and duck.
TEST=trybot run on lumpy-incremental-paladin.

CQ-DEPEND=CL:202748

Change-Id: I0fe0732d47463e880b11d3d547e99dba0ac83ace
Reviewed-on: https://chromium-review.googlesource.com/202771
Tested-by: Bertrand Simonnet <bsimonnet@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Bertrand Simonnet <bsimonnet@chromium.org>
2014-06-18 11:00:49 +00:00
..
init metrics daemon: create /var/run/metrics/uma-events earlier 2014-05-28 10:33:26 +00:00
c_metrics_library.cc Add sparse histograms to the metrics library and metrics client. 2013-04-30 15:54:38 -07:00
c_metrics_library.h Add sparse histograms to the metrics library and metrics client. 2013-04-30 15:54:38 -07:00
inherit-review-settings-ok Setup code review inheritance 2010-06-05 13:12:30 -07:00
libmetrics-271506.gyp libmetrics: Add support for building against libchrome-271506 2014-05-21 20:29:50 +00:00
libmetrics.gypi metrics: Migrate libchromeos to its own ebuild 2014-06-18 11:00:49 +00:00
libmetrics.pc.in libmetrics: add pkg-config file 2014-04-26 00:59:09 +00:00
LICENSE Add LICENSE file 2010-08-05 14:13:48 -07:00
make_tests.sh Add some basic tests for metrics_daemon. 2010-05-05 16:06:37 -07:00
metrics.gyp metrics: Migrate libchromeos to its own ebuild 2014-06-18 11:00:49 +00:00
metrics_client.cc metrics client: add basic sanity check for numeric arguments 2014-04-10 01:18:29 +00:00
metrics_daemon.cc metrics_daemon: add zram stats collection 2014-06-07 01:33:36 +00:00
metrics_daemon.h metrics_daemon: add zram stats collection 2014-06-07 01:33:36 +00:00
metrics_daemon_main.cc metrics_daemon: log to syslog 2014-05-13 00:08:13 +00:00
metrics_daemon_test.cc metrics_daemon: add zram stats collection 2014-06-07 01:33:36 +00:00
metrics_library.cc metrics daemon: create /var/run/metrics/uma-events earlier 2014-05-28 10:33:26 +00:00
metrics_library.h metrics library: complete switchover from /var/log to /var/run 2014-05-19 23:06:27 +00:00
metrics_library_mock.h Add sparse histograms to the metrics library and metrics client. 2013-04-30 15:54:38 -07:00
metrics_library_test.cc metrics daemon: create /var/run/metrics/uma-events earlier 2014-05-28 10:33:26 +00:00
OWNERS Add OWNERS for metrics. 2014-04-03 21:06:44 +00:00
persistent_integer.cc metrics_daemon: store persistent counters in /var/lib, not /var/log. 2014-04-18 03:08:11 +00:00
persistent_integer.h metrics_daemon: fix harmless confusion in writing persistent integers 2014-04-16 17:14:47 +00:00
persistent_integer_mock.h metrics: refactor counters 2014-03-14 19:42:50 +00:00
persistent_integer_test.cc metrics: add PersistentInteger unit test. 2014-03-25 00:32:15 +00:00
platform2_preinstall.sh libmetrics: add pkg-config file 2014-04-26 00:59:09 +00:00
README Add support for user actions to the metrics library and the metrics clients. 2011-01-06 10:51:47 -08:00
syslog_parser.sh Cleanup style nits in metrics daemon. 2010-06-04 15:01:19 -07:00
timer.cc Update to build against libchrome-242728. 2014-02-12 19:39:45 +00:00
timer.h libmetrics: remove version 242728 2014-05-23 04:55:28 +00:00
timer_mock.h Update to build against libchrome-242728. 2014-02-12 19:39:45 +00:00
timer_test.cc Update to build against libchrome-242728. 2014-02-12 19:39:45 +00:00
WATCHLISTS Update Watchlists 2010-06-08 01:33:22 -07:00

Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.

The Chrome OS "metrics" package contains utilities for client-side user metric
collection. The collected data is sent to Chrome for transport to the UMA
server.


================================================================================
The Metrics Library: libmetrics
================================================================================

libmetrics is a small library that implements the basic C and C++ API for
metrics collection. All metrics collection is funneled through this library. The
easiest and recommended way for a client-side module to collect user metrics is
to link libmetrics and use its APIs to send metrics to Chrome for transport to
UMA. In order to use the library in a module, you need to do the following:

- Add a dependence (DEPEND and RDEPEND) on chromeos-base/metrics to the module's
  ebuild.

- Link the module with libmetrics (for example, by passing -lmetrics to the
  module's link command). Both libmetrics.so and libmetrics.a are built and
  installed under $SYSROOT/usr/lib/. Note that by default -lmetrics will link
  against libmetrics.so, which is preferred.

- To access the metrics library API in the module, include the
  <metrics/metrics_library.h> header file. The file is installed in
  $SYSROOT/usr/include/ when the metrics library is built and installed.

- The API is documented in metrics_library.h under src/platform/metrics/. Before
  using the API methods, a MetricsLibrary object needs to be constructed and
  initialized through its Init method.

  For more information on the C API see c_metrics_library.h.

- Samples are sent to Chrome only if the "/home/chronos/Consent To Send Stats"
  file exists (see the AreMetricsEnabled API method). Normally, this file is
  created when the user opts into metrics collection.

- On the target platform, shortly after the sample is sent, it should be visible
  in Chrome through "about:histograms".


================================================================================
Histogram Naming Convention
================================================================================

Use TrackerArea.MetricName. For example:

Logging.CrashCounter
Network.TimeToDrop


================================================================================
Server Side
================================================================================

If the histogram data is visible in about:histograms, it will be sent by an
official Chrome build to UMA, assuming the user has opted into metrics
collection. To make the histogram visible on "chromedashboard", the histogram
description XML file needs to be updated (steps 2 and 3 after following the
"Details on how to add your own histograms" link under the Histograms tab).
Include the string "Chrome OS" in the histogram description so that it's easier
to distinguish Chrome OS specific metrics from general Chrome histograms.

The UMA server logs and keeps the collected field data even if the metric's name
is not added to the histogram XML. However, the dashboard histogram for that
metric will show field data as of the histogram XML update date; it will not
include data for older dates. If past data needs to be displayed, manual
server-side intervention is required. In other words, one should assume that
field data collection starts only after the histogram XML has been updated.


================================================================================
The Metrics Client: metrics_client
================================================================================

metrics_client is a simple shell command-line utility for sending histogram
samples and user actions. It's installed under /usr/bin on the target platform
and uses libmetrics to send the data to Chrome. The utility is useful for
generating metrics from shell scripts.

For usage information and command-line options, run "metrics_client" on the
target platform or look for "Usage:" in metrics_client.cc.


================================================================================
The Metrics Daemon: metrics_daemon
================================================================================

metrics_daemon is a daemon that runs in the background on the target platform
and is intended for passive or ongoing metrics collection, or metrics collection
requiring feedback from multiple modules. For example, it listens to D-Bus
signals related to the user session and screen saver states to determine if the
user is actively using the device or not and generates the corresponding
data. The metrics daemon uses libmetrics to send the data to Chrome.

The recommended way to generate metrics data from a module is to link and use
libmetrics directly. However, the module could instead send signals to or
communicate in some alternative way with the metrics daemon. Then the metrics
daemon needs to monitor for the relevant events and take appropriate action --
for example, aggregate data and send the histogram samples.


================================================================================
FAQ
================================================================================

Q. What should my histogram's |min| and |max| values be set at?

A. You should set the values to a range that covers the vast majority of samples
   that would appear in the field. Note that samples below the |min| will still
   be collected in the underflow bucket and samples above the |max| will end up
   in the overflow bucket. Also, the reported mean of the data will be correct
   regardless of the range.

Q. How many buckets should I use in my histogram?

A. You should allocate as many buckets as necessary to perform proper analysis
   on the collected data. Note, however, that the memory allocated in Chrome for
   each histogram is proportional to the number of buckets. Therefore, it is
   strongly recommended to keep this number low (e.g., 50 is normal, while 100
   is probably high).

Q. When should I use an enumeration (linear) histogram vs. a regular
   (exponential) histogram?

A. Enumeration histograms should really be used only for sampling enumerated
   events and, in some cases, percentages. Normally, you should use a regular
   histogram with exponential bucket layout that provides higher resolution at
   the low end of the range and lower resolution at the high end. Regular
   histograms are generally used for collecting performance data (e.g., timing,
   memory usage, power) as well as aggregated event counts.