diff options
author | Steve Fung <stevefung@google.com> | 2016-06-29 15:45:53 -0700 |
---|---|---|
committer | Alex Deymo <deymo@google.com> | 2016-09-13 09:16:53 -0700 |
commit | a9a6af0e7b1caa54dad41cb184945e10e242cb38 (patch) | |
tree | 041cb80c0956893389dffef9a3a5481e72e28914 | |
parent | caacd6905920128af1de8d7f93463eee88be1646 (diff) | |
download | metricsd-a9a6af0e7b1caa54dad41cb184945e10e242cb38.tar.gz |
Fix metricsd compile issues in new repository
This fixes a few issues:
- Fixes proto absolute paths for new system/metricsd location
- Conditionally builds in weave support behind a use flag
Bug: 29835922
(cherry picked from commit a7840a0353e7675158ac4a4bdb679cc5ea6ff72a)
Change-Id: Iff5c5bef9759ecdc071e9608dbdd41dcc0748f4b
-rw-r--r-- | Android.mk | 14 | ||||
-rw-r--r-- | metrics_collector.cc | 6 | ||||
-rw-r--r-- | metrics_collector.h | 8 | ||||
-rw-r--r-- | uploader/proto/chrome_user_metrics_extension.proto | 6 |
4 files changed, 29 insertions, 5 deletions
@@ -14,6 +14,11 @@ LOCAL_PATH := $(call my-dir) +# Default values for the USE flags. Override these USE flags from your product +# by setting BRILLO_USE_* values. Note that we define local variables like +# local_use_* to prevent leaking our default setting for other packages. +local_use_weave := $(if $(BRILLO_USE_WEAVE),$(BRILLO_USE_WEAVE),0) + metrics_cpp_extension := .cc libmetrics_sources := \ c_metrics_library.cc \ @@ -64,6 +69,7 @@ metrics_CFLAGS := -Wall \ -Werror \ -fvisibility=default metrics_CPPFLAGS := -Wno-non-virtual-dtor \ + -DUSE_WEAVE=$(local_use_weave) \ -Wno-sign-promo \ -Wno-strict-aliasing \ -fvisibility=default @@ -74,8 +80,12 @@ metrics_collector_shared_libraries := $(libmetrics_shared_libraries) \ libbrillo-binder \ libbrillo-http \ libmetrics \ - librootdev \ + librootdev + +ifeq ($(local_use_weave),1) +metrics_collector_shared_libraries += \ libweaved +endif # local_use_weave == 1 metrics_collector_static_libraries := libmetricscollectorservice @@ -148,7 +158,7 @@ LOCAL_MODULE := metricsd_protos LOCAL_MODULE_CLASS := STATIC_LIBRARIES generated_sources_dir := $(call local-generated-sources-dir) LOCAL_EXPORT_C_INCLUDE_DIRS += \ - $(generated_sources_dir)/proto/system/core/metricsd + $(generated_sources_dir)/proto/system/metricsd LOCAL_SRC_FILES := $(call all-proto-files-under,uploader/proto) include $(BUILD_STATIC_LIBRARY) diff --git a/metrics_collector.cc b/metrics_collector.cc index 45ae0a4..318caa0 100644 --- a/metrics_collector.cc +++ b/metrics_collector.cc @@ -69,8 +69,10 @@ const int kMetricMeminfoInterval = 30; // seconds const char kMeminfoFileName[] = "/proc/meminfo"; const char kVmStatFileName[] = "/proc/vmstat"; +#if USE_WEAVE const char kWeaveComponent[] = "metrics"; const char kWeaveTrait[] = "_metrics"; +#endif // USE_WEAVE } // namespace @@ -231,10 +233,12 @@ int MetricsCollector::OnInit() { if (testing_) return EX_OK; +#if USE_WEAVE weave_service_subscription_ = weaved::Service::Connect( brillo::MessageLoop::current(), base::Bind(&MetricsCollector::OnWeaveServiceConnected, weak_ptr_factory_.GetWeakPtr())); +#endif // USE_WEAVE latest_cpu_use_microseconds_ = cpu_usage_collector_->GetCumulativeCpuUse(); base::MessageLoop::current()->PostDelayedTask(FROM_HERE, @@ -245,6 +249,7 @@ int MetricsCollector::OnInit() { return EX_OK; } +#if USE_WEAVE void MetricsCollector::OnWeaveServiceConnected( const std::weak_ptr<weaved::Service>& service) { service_ = service; @@ -309,6 +314,7 @@ void MetricsCollector::UpdateWeaveState() { LOG(ERROR) << "failed to update weave's state"; } } +#endif // USE_WEAVE void MetricsCollector::ProcessUserCrash() { // Counts the active time up to now. diff --git a/metrics_collector.h b/metrics_collector.h index 30659bd..297a968 100644 --- a/metrics_collector.h +++ b/metrics_collector.h @@ -29,8 +29,10 @@ #include <base/time/time.h> #include <brillo/binder_watcher.h> #include <brillo/daemons/daemon.h> +#if USE_WEAVE #include <libweaved/command.h> #include <libweaved/service.h> +#endif // USE_WEAVE #include <gtest/gtest_prod.h> // for FRIEND_TEST #include "collectors/averaged_statistics_collector.h" @@ -112,6 +114,7 @@ class MetricsCollector : public brillo::Daemon { int value; // value from /proc/meminfo }; +#if USE_WEAVE // Enables metrics reporting. void OnEnableMetrics(std::unique_ptr<weaved::Command> command); @@ -120,6 +123,7 @@ class MetricsCollector : public brillo::Daemon { // Updates the weave device state. void UpdateWeaveState(); +#endif // USE WEAVE // Updates the active use time and logs time between kernel crashes. void ProcessKernelCrash(); @@ -215,9 +219,11 @@ class MetricsCollector : public brillo::Daemon { // Reads a string from a file and converts it to uint64_t. static bool ReadFileToUint64(const base::FilePath& path, uint64_t* value); +#if USE_WEAVE // Callback invoked when a connection to weaved's service is established // over Binder interface. void OnWeaveServiceConnected(const std::weak_ptr<weaved::Service>& service); +#endif // USE_WEAVE // VARIABLES @@ -275,8 +281,10 @@ class MetricsCollector : public brillo::Daemon { unique_ptr<DiskUsageCollector> disk_usage_collector_; unique_ptr<AveragedStatisticsCollector> averaged_stats_collector_; +#if USE_WEAVE unique_ptr<weaved::Service::Subscription> weave_service_subscription_; std::weak_ptr<weaved::Service> service_; +#endif // USE_WEAVE base::WeakPtrFactory<MetricsCollector> weak_ptr_factory_{this}; }; diff --git a/uploader/proto/chrome_user_metrics_extension.proto b/uploader/proto/chrome_user_metrics_extension.proto index a07830f..80c9097 100644 --- a/uploader/proto/chrome_user_metrics_extension.proto +++ b/uploader/proto/chrome_user_metrics_extension.proto @@ -26,9 +26,9 @@ option java_package = "org.chromium.components.metrics"; package metrics; -import "system/core/metricsd/uploader/proto/histogram_event.proto"; -import "system/core/metricsd/uploader/proto/system_profile.proto"; -import "system/core/metricsd/uploader/proto/user_action_event.proto"; +import "system/metricsd/uploader/proto/histogram_event.proto"; +import "system/metricsd/uploader/proto/system_profile.proto"; +import "system/metricsd/uploader/proto/user_action_event.proto"; // Next tag: 13 message ChromeUserMetricsExtension { |