Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1743fb7d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "reretry ValueMetric implementation and pulling mechanism"

parents 01f5db72 b3dda41a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ statsd_common_src := \
    src/metrics/DurationMetricProducer.cpp \
    src/metrics/duration_helper/OringDurationTracker.cpp \
    src/metrics/duration_helper/MaxDurationTracker.cpp \
    src/metrics/ValueMetricProducer.cpp \
    src/metrics/MetricsManager.cpp \
    src/metrics/metrics_manager_util.cpp \
    src/packages/UidMap.cpp \
+3 −3
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ void CompanionDeathRecipient::binderDied(const wp<IBinder>& who) {
StatsService::StatsService(const sp<Looper>& handlerLooper)
    : mAnomalyMonitor(new AnomalyMonitor(2))  // TODO: Put this comment somewhere better
{
    mStatsPullerManager = new StatsPullerManager();
    mUidMap = new UidMap();
    mConfigManager = new ConfigManager();
    mProcessor = new StatsLogProcessor(mUidMap, [this](const vector<uint8_t>& log) {
@@ -374,7 +373,7 @@ status_t StatsService::cmd_print_uid_map(FILE* out) {

status_t StatsService::cmd_print_pulled_metrics(FILE* out, const Vector<String8>& args) {
    int s = atoi(args[1].c_str());
    auto stats = mStatsPullerManager->Pull(s);
    auto stats = m_stats_puller_manager.Pull(s, time(nullptr));
    for (const auto& it : stats) {
        fprintf(out, "Pull from %d: %s\n", s, it->ToString().c_str());
    }
@@ -441,8 +440,9 @@ Status StatsService::informPollAlarmFired() {
                                         "Only system uid can call informPollAlarmFired");
    }

    m_stats_puller_manager.OnAlarmFired();

    if (DEBUG) ALOGD("StatsService::informPollAlarmFired succeeded");
    // TODO: determine what services to poll and poll (or ask StatsCompanionService to poll) them.

    return Status::ok();
}
+1 −2
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include <android/os/IStatsCallbacks.h>
#include <android/os/IStatsCompanionService.h>
#include <binder/IResultReceiver.h>
#include <binder/IShellCallback.h>
#include <utils/Looper.h>

#include <deque>
@@ -158,7 +157,7 @@ private:
    /**
     * Fetches external metrics.
     */
    sp<StatsPullerManager> mStatsPullerManager;
    StatsPullerManager& m_stats_puller_manager = StatsPullerManager::GetInstance();

    /**
     * Tracks the configurations that have been passed to statsd.
+14 −0
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ static StatsdConfig build_fake_config() {
    int UID_PROCESS_STATE_TAG_ID = 27;
    int UID_PROCESS_STATE_UID_KEY = 1;

    int KERNEL_WAKELOCK_TAG_ID = 41;
    int KERNEL_WAKELOCK_NAME_KEY = 4;

    // Count Screen ON events.
    CountMetric* metric = config.add_count_metric();
    metric->set_metric_id(1);
@@ -228,6 +231,17 @@ static StatsdConfig build_fake_config() {
    durationMetric->set_type(DurationMetric_AggregationType_DURATION_SUM);
    durationMetric->set_what("SCREEN_IS_ON");

    // Value metric to count KERNEL_WAKELOCK when screen turned on
    ValueMetric* valueMetric = config.add_value_metric();
    valueMetric->set_metric_id(6);
    valueMetric->set_what("KERNEL_WAKELOCK");
    valueMetric->set_value_field(1);
    valueMetric->set_condition("SCREEN_IS_ON");
    keyMatcher = valueMetric->add_dimension();
    keyMatcher->set_key(KERNEL_WAKELOCK_NAME_KEY);
    // This is for testing easier. We should never set bucket size this small.
    valueMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L);

    // Add an EventMetric to log process state change events.
    EventMetric* eventMetric = config.add_event_metric();
    eventMetric->set_metric_id(9);
+3 −3
Original line number Diff line number Diff line
@@ -14,14 +14,14 @@
 * limitations under the License.
 */

#define DEBUG true
#include "Log.h"

#include <android/os/IStatsCompanionService.h>
#include <binder/IPCThreadState.h>
#include <private/android_filesystem_config.h>
#include "KernelWakelockPuller.h"
#include "StatsService.h"
#include "external/KernelWakelockPuller.h"
#include "external/StatsPuller.h"

using namespace android;
using namespace android::base;
@@ -37,7 +37,7 @@ const int KernelWakelockPuller::PULL_CODE_KERNEL_WAKELOCKS = 20;

// The reading and parsing are implemented in Java. It is not difficult to port over. But for now
// let StatsCompanionService handle that and send the data back.
vector<StatsLogEventWrapper> KernelWakelockPuller::pull() {
vector<StatsLogEventWrapper> KernelWakelockPuller::Pull() {
    sp<IStatsCompanionService> statsCompanion = StatsService::getStatsCompanionService();
    vector<StatsLogEventWrapper> returned_value;
    if (statsCompanion != NULL) {
Loading