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

Commit 61a700f6 authored by Howard Ro's avatar Howard Ro Committed by android-build-merger
Browse files

Merge "Revert "Make native metrics logger write to statsd socket""

am: 18a936b3

Change-Id: I046ca998a78397028e6705061bb58f33248742c0
parents bc57c794 18a936b3
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -11,11 +11,7 @@ cc_defaults {

    export_include_dirs: ["include"],
    local_include_dirs: ["include"],
    shared_libs: [
        "libbase",
        "liblog",
        "libstatssocket",
    ],
    shared_libs: ["liblog"],
    whole_static_libs: ["libgtest_prod"],

    cflags: [
@@ -27,20 +23,17 @@ cc_defaults {

// metricslogger shared library
// -----------------------------------------------------------------------------
cc_library {
cc_library_shared {
    name: "libmetricslogger",
    srcs: metricslogger_lib_src_files,
    defaults: ["metricslogger_defaults"],
    export_shared_lib_headers: ["libstatssocket"],
}

// static version of libmetricslogger, needed by a few art static binaries
// TODO(b/117829226): Remove once dependencies are cleaned up.
cc_library_static {
    name: "libmetricslogger_static",
    srcs: metricslogger_lib_src_files,
    defaults: ["metricslogger_defaults"],
    export_shared_lib_headers: ["libstatssocket"],
}

// metricslogger shared library, debug
+0 −2
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */

#include <log/log_event_list.h>
#include <stats_event_list.h>
#include <cstdint>
#include <string>

@@ -44,7 +43,6 @@ void LogMultiAction(int32_t category, int32_t field, const std::string& value);
class ComplexEventLogger {
  private:
    android_log_event_list logger;
    stats_event_list stats_logger;

  public:
    // Create a complex event with category|category|.
+2 −37
Original line number Diff line number Diff line
@@ -18,15 +18,11 @@

#include <cstdlib>

#include <android-base/chrono_utils.h>
#include <log/event_tag_map.h>

using namespace android;
#include <log/log_event_list.h>

namespace {

const static int kStatsEventTag = 1937006964;
const static int kKeyValuePairAtomId = 83;
#ifdef __ANDROID__
EventTagMap* kEventTagMap = android_openEventTagMap(nullptr);
const int kSysuiMultiActionTag = android_lookupEventTagNum(
@@ -36,12 +32,6 @@ const int kSysuiMultiActionTag = android_lookupEventTagNum(
const int kSysuiMultiActionTag = 0;
#endif

int64_t getElapsedTimeNanoSinceBoot() {
    return std::chrono::duration_cast<std::chrono::nanoseconds>(
                   android::base::boot_clock::now().time_since_epoch())
            .count();
}

}  // namespace

namespace android {
@@ -52,12 +42,6 @@ void LogHistogram(const std::string& event, int32_t data) {
    android_log_event_list log(kSysuiMultiActionTag);
    log << LOGBUILDER_CATEGORY << LOGBUILDER_HISTOGRAM << LOGBUILDER_NAME << event
        << LOGBUILDER_BUCKET << data << LOGBUILDER_VALUE << 1 << LOG_ID_EVENTS;

    stats_event_list stats_log(kStatsEventTag);
    stats_log << getElapsedTimeNanoSinceBoot() << kKeyValuePairAtomId << LOGBUILDER_CATEGORY
              << LOGBUILDER_HISTOGRAM << LOGBUILDER_NAME << event << LOGBUILDER_BUCKET << data
              << LOGBUILDER_VALUE << 1;
    stats_log.write(LOG_ID_STATS);
}

// Mirror com.android.internal.logging.MetricsLogger#count().
@@ -65,11 +49,6 @@ void LogCounter(const std::string& name, int32_t val) {
    android_log_event_list log(kSysuiMultiActionTag);
    log << LOGBUILDER_CATEGORY << LOGBUILDER_COUNTER << LOGBUILDER_NAME << name << LOGBUILDER_VALUE
        << val << LOG_ID_EVENTS;

    stats_event_list stats_log(kStatsEventTag);
    stats_log << getElapsedTimeNanoSinceBoot() << kKeyValuePairAtomId << LOGBUILDER_CATEGORY
              << LOGBUILDER_COUNTER << LOGBUILDER_NAME << name << LOGBUILDER_VALUE << val;
    stats_log.write(LOG_ID_STATS);
}

// Mirror com.android.internal.logging.MetricsLogger#action().
@@ -77,48 +56,34 @@ void LogMultiAction(int32_t category, int32_t field, const std::string& value) {
    android_log_event_list log(kSysuiMultiActionTag);
    log << LOGBUILDER_CATEGORY << category << LOGBUILDER_TYPE << TYPE_ACTION
        << field << value << LOG_ID_EVENTS;

    stats_event_list stats_log(kStatsEventTag);
    stats_log << getElapsedTimeNanoSinceBoot() << kKeyValuePairAtomId << LOGBUILDER_CATEGORY
              << category << LOGBUILDER_TYPE << TYPE_ACTION << field << value;
    stats_log.write(LOG_ID_STATS);
}

ComplexEventLogger::ComplexEventLogger(int category)
    : logger(kSysuiMultiActionTag), stats_logger(kStatsEventTag) {
ComplexEventLogger::ComplexEventLogger(int category) : logger(kSysuiMultiActionTag) {
    logger << LOGBUILDER_CATEGORY << category;
    stats_logger << getElapsedTimeNanoSinceBoot() << kKeyValuePairAtomId << LOGBUILDER_CATEGORY
                 << category;
}

void ComplexEventLogger::SetPackageName(const std::string& package_name) {
    logger << LOGBUILDER_PACKAGENAME << package_name;
    stats_logger << LOGBUILDER_PACKAGENAME << package_name;
}

void ComplexEventLogger::AddTaggedData(int tag, int32_t value) {
    logger << tag << value;
    stats_logger << tag << value;
}

void ComplexEventLogger::AddTaggedData(int tag, const std::string& value) {
    logger << tag << value;
    stats_logger << tag << value;
}

void ComplexEventLogger::AddTaggedData(int tag, int64_t value) {
    logger << tag << value;
    stats_logger << tag << value;
}

void ComplexEventLogger::AddTaggedData(int tag, float value) {
    logger << tag << value;
    stats_logger << tag << value;
}

void ComplexEventLogger::Record() {
    logger << LOG_ID_EVENTS;
    stats_logger.write(LOG_ID_STATS);
}

}  // namespace metricslogger
+1 −3
Original line number Diff line number Diff line
@@ -17,13 +17,12 @@
// ==========================================================
// Native library to write stats log to statsd socket
// ==========================================================
cc_library {
cc_library_static {
    name: "libstatssocket",
    srcs: [
        "stats_event_list.c",
        "statsd_writer.c",
    ],
    host_supported: true,
    cflags: [
        "-Wall",
        "-Werror",
@@ -33,7 +32,6 @@ cc_library {
    ],
    export_include_dirs: ["include"],
    shared_libs: [
        "libcutils",
        "liblog",
    ],
}
+0 −2
Original line number Diff line number Diff line
@@ -15,9 +15,7 @@
 */
#include "statsd_writer.h"

#include <cutils/fs.h>
#include <cutils/sockets.h>
#include <cutils/threads.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>