Now that scoped_ptr is just a type alias to unique_ptr, there is no
longer a need to convert between the two by using .release() and
constructing the other with a raw pointer.
BUG: None
TEST: Built for dragonboard, all unit tests pass (except for update_engine,
but those tests failed before these changes too).
Change-Id: Ibf0a094805d22d00ca10e1c67f68efb08c8677df
libmetric's HistogramSnapshotManager::PrepareDeltas now takes the
iterators for the histogram collection to work on, instead of getting
a global one.
Change-Id: I3997ea7d2c330431379d055b0cb876069bddf395
This patch replaces the locally defined clang-format with a symlink
to the one defined in build/tools.
Bug: 27121653
TEST=Ran clang-format.
Change-Id: I8810428d12b60c7463bc7f9a96228600ec8b425d
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
Weaved replaces brillo::Any with base::Value in its client library,
so need to update clients.
Also this removes last D-Bus dependencies from metrics_collector.
BUG: 26558300
Change-Id: I82d571d7e2bd17347daeb1b70f48ec05378894f0
Without this setting, arguments passed to a function can be packed in
more than one line, with more than one argument per line.
For example, the following code will be formated as this without the
BinPackArguments:
CallMyFunction(
with_more_than_one, argument_per_line,
event_they_dont_fit_in_a_single_line);
On the other hand, with BinPackArguments: false, that code will be
split in:
CallMyFunction(
with_more_than_one,
argument_per_line,
event_they_dont_fit_in_a_single_line);
or all the arguments in the same line if they all fit.
Bug: None
TEST=None
Change-Id: I48627e66e2a841f89418c0763e7fe6c3e6ea7387
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
This will allow the tests to be run by the continuous builder.
Bug: 26571398
Change-Id: I7eae2761603e83e3d1f003cb3b06582abc4ed24f
Test: Build an eng build. The tests are installed.
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
weaved::Service::AddCommandHandler() and SetStateProperty() now
expect the trait name as a separate argument.
BUG: 26443877
Change-Id: I2ad587d984375a7ebd70c7dc804b446b66d6be1b
Now that weaved provides a binder interface for its IPC, switch
to using it instead.
BUG: 23782171
Change-Id: Ic3c485f99580fe41e287eaf238f033149787f181
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
/data/misc/metricsd only needs to be accessed by metricsd.
/data/misc/metrics_collector only needs to be accessed by
metrics_collector.
/data/misc/metrics needs to be writable by metrics_collector
and readable by metricsd. Make it 0750 metrics_collector:system
and keep running metricsd as group 'system' to allow reading.
Bug: 26337609
Change-Id: I169573cc547f154daa8b65c5f13bdc20964a3f2c
IMetricsCollectorService implementation moved from libmetricscollectorservice
to metrics_collector executable, which means it needs to be compiled into test
main as well.
Bug: None
Change-Id: I29b0a3ae6164d2256366d61c3a3639d22b943a69
No longer needed to trampoline between RTTI and non-RTTI compiles.
Move the service impl from libmetricscollector service to the
metrics_collector executable, now that RTTI is no longer used (and the impl
is not used by binder clients).
Other fixups, including:
* Move service registration and binder watcher to metrics_collector main.
* Compile libmetricscollectorservice with clang just because.
Bug: 26292405
Change-Id: Iae8115c13b203ff03d49bf7678d5eb3ede30e855
There is no longer a reliance on RTTI in libbrillo, so disable RTTI
in the rest of Brillo codebase.
Bug: 26292405
Change-Id: I2751a2ac973a74741a82f5cd949fc0adaf2449a6
The new server push enabled component/trait validation rules. This
allows us to use the new schema that does not require vendor commands,
parameters and state to start with underscore ("_").
Also fixed a few minor errors in schema definition.
Change-Id: I184dd8e4c69c05e0dd1b0dddb1f9a7b0aef78841
Switch user crash event notification from D-Bus to this Binder service.
Add a trampoline as a go-between for the -frtti and -fno-rtti sources.
Add MetricsCollectorServiceClient for crash_reporter to use, hiding the
binder proxy details.
Remove D-Bus message filtering from metrics_collector.
Bug: 25929888
Change-Id: Idcdd60ac476340fb11602fc9afab6cd87843e529
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
Removed command and state definitions and use trait definitions
instead. Also, create "metrics" component for weave.
BUG: 25916429, 25916428, 25917426
Change-Id: Icc02d1c46c371d3afa8e4723852f182992c62bf2
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
This will make it easier to catch formatting nits.
This style is based on the Google style guide (well known publicly) and
follows the Chromium style changes we have adopted.
Bug: 25887990
Change-Id: If9562223752dfe611a32c341e703338f806bcc0f
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.
We don't report the cpu frequency, we can remove that part of the code.
Bug: 25693224
Test: unit tests.
Change-Id: I510654a74261dbd66b7183ea54eef1e1eadc4d91
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
metricsd should only log to a single location (stderr or syslog):
* standard error if --logtostderr is set or metricsd runs in the
foreground.
* syslog if --logtosyslog is set or metricsd is daemonized.
Bug: 25472752
Change-Id: Idb918714e1b6975d79682f22495a7ca708d4d97d
Collect a new histogram (Platform.CpuUsage.Percent), collecting the
average cpu usage in percent of the total cpu usage possible (across all
cpus).
This measurement is collected every minute.
Bug: 25231576
Test: unit tests.
Test: Manual testing.
Change-Id: I1c63486c177f0c2d4bd361eb9e351a7ca25b80d9
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
The /data directory isn't guaranteed to be mounted during the
"on boot" trigger, so switch them to using "on post-fs-data".
Bug: 24941965
Change-Id: Iee84ca0e934967cff7bc4d968d9939d398c73980