* Use const reference type for parameters to avoid unnecessary copy.
Bug: 30407689
Change-Id: I5e6bfd1cd3bcf54666316573281b79573cd8a780
Test: build with WITH_TIDY=1
The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.
Change-Id: I0a0e0441b6a7486ff0b42d11136254d8a536788f
libmetric's HistogramSnapshotManager::PrepareDeltas now takes the
iterators for the histogram collection to work on, instead of getting
a global one.
Change-Id: I3997ea7d2c330431379d055b0cb876069bddf395
The unittest was creating a brillo::Daemon in a smart pointer and then
resetting it to a newly created different brillo::Daemon instance. This
creates two brillo::Daemon instances for a short period of time, which
both setup global context (the default message loop).
This patch fixes this situation by deleting the service before creating
a new one.
Bug: 27121855
TEST=`/data/nativetest/metricsd_tests/metricsd_tests` on edison-eng
Change-Id: I3b60cbfcdba77febbfa6104aa0ecad60a29afec5
brillo::BinderWatcher now requires a brillo::MessageLoop, so this patch
creates a brillo::BaseMessageLoop and passes it when creating the
brillo::BinderWatcher.
Bug: 26356682
TEST=Deployed metricsd to edison-eng.
Change-Id: I6a9e592623faf231205ae44e479bec2b873b8898
This CL adds two more checks:
* When populating a closed log with the metadata, make sure the
SystemProfileSetter is not null.
* When using the update engine client library, check if the update
engine client object was created correctly. The returning object can
be null if update engine's binder service is not running.
Bug: 26731548
Change-Id: I8a615c87f33e15a163d56ccfa3a932a0908aac5f
The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.
Change-Id: I9e45975cdef43913270b82e3fca2c027e614a464
When metricsd receives a SIGTERM signal (on system shutdown for
example), save the metrics to disk before exiting.
Bug: 26184202
Test: Start metricsd. Log a metric sample. Stop metricsd. The metric is
saved to disk.
Change-Id: Ib224efa8837130393fac5d06fa80d320263cfc84
Every now and then (5 minutes by default), the uploader will persist the
current metrics to disk to avoid losing them in case we exit
unexpectedly (reboot or crash).
When starting up, metricsd will load the previously saved log and resume
the metrics collection from there.
Bug: 25670584
Test: Unit tests.
Test: manual: restart metricsd. The saved log is detected and parsed
correctly.
Test: manual: Send a sample to metricsd, send SIGTERM to metricsd, the
log is saved to disk, metricsd restarts and picks up the log where it
left.
Change-Id: I4cefc62c7ea1fa51333d84d8a7ba0a2e9c7fd58f
metricsd should shutdown cleanly when receiving a TERM signal:
* stop the binder watcher.
* wait for the thread to quit.
* Exit cleanly.
Note: This is not directly used as we don't send SIGTERM on shutdown or
when stopping services yet.
Bug: 25670584
Change-Id: I878d1e67474c72d24790f3540470e37a23112a95
This fixes the documentation for UploadService and the README file:
* stop mentioning Chrome OS as we forked the code.
* update the histogram declaration workflow. It is not tied to Chrome's
histograms.xml file anymore.
* update the architecture explanation of metricsd. We split
metrics_daemon into two daemons and are now using binder to log
metrics.
* convert README to markdown to make it prettier when viewed in gitiles.
Bug: 26314417
Change-Id: I1e492f1211c1784e65dd4d3e473bb9aacefc3b5d
Assert abort metricsd if binder service registration fails.
If the addService() call fails (for reasons that at least include an SELinux
policy denial), the call to joinThreadPool() apparently processes a stale
pending weak dereference that triggers an abort on a probable double-free:
F libc : Invalid address 0xbe8bfa30 passed to free: value not allocated
F libc : Fatal signal 6 (SIGABRT), code -6 in tid 609 (metricsd)
Since metricsd is severely hobbled if registration fails, abort and see if
things work better the next time. If not, the crash loop will hopefully
attract attention to the problem.
Change-Id: I520d0eafb9cb25ee225d589bfd87df4e51f6b181
This CL adds a dump command to metrics_client that will dump the
histograms, aggregated by metricsd since it started, in a human readable
format.
This is useful for developers to ensure that their code uses libmetrics
correctly and the reported values are correct.
Sample output (redacted to fit the commit message):
$ metrics_client -d
Histogram: hello recorded 5 samples, average = 54.8 (flags = 0x1)
0 ...
9 --------O (1 = 20.0%) {0.0%}
16 O (0 = 0.0%) {20.0%}
29 --------O (1 = 20.0%) {20.0%}
54 ------------------------O (3 = 60.0%) {40.0%}
100 O (0 = 0.0%) {100.0%}
$
Bug: 25817310
Test: * Send a histogram with metrics_client.
* `metrics_client -d` shows it.
Change-Id: Id186dc5463403ca9181ee9eef8f46b5e809b8714
This CL converts metricsd, libmetrics and metrics_collector to use
Binder to pass metrics samples.
Bug: 25670685
Change-Id: I657faecdf4ed1226ab30ce69e062028463437e7b
Instead of using a single directory for both the internal data of
metricsd and metrics_collector and the shared files (metrics samples log
file and the metrics enabled file), we should use separate directory to
allow for a finer access control.
The new structure will be:
* /data/misc/metrics for the files accessible to all daemons reporting
metrics, metricsd and metrics_collector.
* /data/misc/metricsd for the private files of metricsd.
* /data/misc/metrics_collector for the private files of
metrics_collector.
Bug: 25886951
Test: Unit tests.
Test: Manual: metricsd and metrics_collector run without errors.
Change-Id: I006d19f45f5f419d2b08744126c2e2a0b899c9fa
Instead of using a global directory for persistent integers, specify the
directory to use in the constructor.
This will make changing the backing directory easier.
Bug: 25886951
Change-Id: I590816b195fa81b179a5ec78b9cdf41bc86353dc
This CL splits metrics_daemon into two independent daemons: metricsd and
metrics_collector.
* metricsd will be responsible for reading the metrics from disk and
periodically uploading them to the server.
* metrics_collector will be responsible for gathering generic metrics
from the system and managing the weave state for metrics.
This refactoring is necessary to prepare the migration of metricsd to
log over binder.
Bug: 25670908
Test: Unit tests.
Test: manual: both daemons run. Metrics are logged, uploaded and the
weave interaction works.
Change-Id: Ib00e1772bb7eec87cbcdcd912c30b555d79d7074
If the product id is not set, the product_id file might exist but be
empty. In this case, to try to update the metrics.
Bug: 25745391
Change-Id: I3942afaf38921b44ddb7e5a29d5d0e4fb6d48d94
Test: Unit tests.
libupdate_engine_client returns the channel as "stable-channel",
"dev-channel" or "beta-channel". This CL updates the parsing logic to
match this format.
Bug: 25669566
Test: unit tests
Test: manual: The reported channel matches what update_engine_client
--show_channel reports.
Change-Id: Ic6e52df892ae0b438f58fc05b178d5844d6674d0
When the model manifest id is defined in weave, report it.
Bug: 25386505
Test: the model manifest id is uploaded when defined.
Test: If weaved.conf is not defined, metricsd uploads the default value.
Change-Id: Ic895671621fda9ce5cdeacdbdba58aa73a6887fc
So that this daemon doesn't change on every build, use the system build
date from libchrome (which reads ro.build.date). That way we don't have
to update this daemon for every OTA.
Bug: 24204119
Change-Id: I136d53e5e4ebb9430a57dace66198d8d704d7ca3
This stops relying on system properties to provide build time
configuration.
Product version and id will be stored in /etc/os-release.d.
Channel will be pulled from update engine.
BUG: 24947119
Change-Id: I0972d03cd83ef622846de3cce3dec1992fcc46cd
libchromeos is transitioning to libbrillo and chromeos namespaces
and include directory is changing to brillo.
Bug: 24872993
Change-Id: I797613a38c7444a113f12e38366a424388477276
We use product_id instead of build_target_id, the protobuffer should
rename that field too to be consistent.
The same change was made on the backend.
BUG: 24712895
Change-Id: Id9492e3debab986c9df7d4ec0caef8730eb14240
We cached the enabled status for metrics as a static field in the
metrics library. This field is not reset in between tests which treats
the metrics as enabled if they were enabled previously.
None of the users rely on the caching being static so the cached status
was changed into a field.
Also enabled the metrics in upload_service_test.cc after verifying that
the test failed consistently.
BUG: 24473349
TEST: unit tests.
Change-Id: If05fdca644016d923aa7b1978db5e74ada563c1a
We decided to change the name of this identifier to "product id", the
system property where it is stored will also be named
ro.product.product_id.
BUG: 24302729
Change-Id: I0d2f0867b364de98367f0072d216acec76401c33
Move metrics_library_mock.h and timer_mock.h into the include/metrics/
folder since some source files in shill need to include these header files.
Adjust the include paths in metricsd source files accordingly, and add
the -frtti flag to the libmetrics target so that classes including
these mock headers can determine the type information of the underlying
class being mocked at run-time.
BUG: 22956441
Change-Id: I19820c0d3097c9c4c2b93730d1988ccec563db23
TEST: "mma" in metricsd folder succeeds.
This test case ensures that we can log a metric with the metrics library
and upload it with the upload service.
BUG: 22879646
TEST: unit tests.
Change-Id: Idf4a1240d41745ebf7835089230608082eed19f5
If the metrics server is unreachable, we may need to resend a metrics
report later. Instead of keeping the staged report in memory, save it to
disk to avoid loosing data if the system restarts or crashes.
BUG: 23033262
TEST: unit tests.
Change-Id: Idd14964e40f022952469f47d675d8cda9586d7cd
Instead of passing different filenames around, only rely on the metrics
directory and infer the filepath from it. This makes testing easier.
BUG: 23939404
TEST: unit tests.
Change-Id: I79086acc3a546464114fa8ec4656ec04e1c43e35
When running the metrics_daemon in verbose mode, log the histogram name
along with the hash name.
This is useful when debugging as the protobuf message only contains the
hash of the name.
Change-Id: Ifea7edce55d62d30994ec7b75bb8728f6a0c40e8
This cleans up the unit tests and update them to pass.
Cleaned up:
* removed the irrelevant bits.
* Used ScopedTempDir for all test specific files (instead of the current
directory).
* Update some objects to make them more easily testable.
* Group all the test in a single binary and use bionic's test runner.
BUG: 23682444
Change-Id: I289e3a5ff89968fdecd4a156e93bc38bbc25f58b
Instead of using /etc/lsb-release to store the version, channel and
build_target_id, use the Android system properties.
BUG: 22879642
Change-Id: Ic79e74bd14bf8e2c55549c08963a66700b49b544
Instead of crashing when the build target id is missing, simply print a
useful warning and discard the log.
BUG: 23351227
Change-Id: I3abf3063d6440b07103db29938eec5071ea8f60b
MODULE_LICENSE_BSD and NOTICE were removed as the license is no longer
different from the rest of system/core.
BUG: 23086670
Change-Id: I1e83ef2ecb9c721150f8aab283c9ff960337da8c
This makes the import path less confusing:
* metrics/metrics_library.h is imported from the exported headers.
* metricsd/* for includes by the metrics daemon itself.
BUG: 22879597
Change-Id: I9f44ea3a548cae39d4546fcd724e8007f6dd4bd0