From c246440dc5b12d68cf63bf6e4fa0ea02af7c4247 Mon Sep 17 00:00:00 2001 From: Vova Sharaienko Date: Thu, 23 Mar 2023 20:52:49 +0000 Subject: [PATCH] [TeX] Introduced Telemetry Express Logging APIs - provided C++ Histogram metric logging API with UID Bug: 266586106 Test: m Change-Id: I2ee92d423be5f9c137fa160d8c744340972f8036 --- libstats/expresslog/Histogram.cpp | 5 +++++ libstats/expresslog/include/Histogram.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/libstats/expresslog/Histogram.cpp b/libstats/expresslog/Histogram.cpp index cb29a00a9..50bb343af 100644 --- a/libstats/expresslog/Histogram.cpp +++ b/libstats/expresslog/Histogram.cpp @@ -71,5 +71,10 @@ void Histogram::logSample(float sample) const { stats_write(EXPRESS_HISTOGRAM_SAMPLE_REPORTED, mMetricIdHash, /*count*/ 1, binIndex); } +void Histogram::logSampleWithUid(int32_t uid, float sample) const { + const int binIndex = mBinOptions->getBinForSample(sample); + stats_write(EXPRESS_UID_HISTOGRAM_SAMPLE_REPORTED, mMetricIdHash, /*count*/ 1, binIndex, uid); +} + } // namespace expresslog } // namespace android diff --git a/libstats/expresslog/include/Histogram.h b/libstats/expresslog/include/Histogram.h index 8fdc1b684..49aee3d9c 100644 --- a/libstats/expresslog/include/Histogram.h +++ b/libstats/expresslog/include/Histogram.h @@ -72,6 +72,11 @@ public: */ void logSample(float sample) const; + /** + * Logs increment sample count for automatically calculated bin with uid + */ + void logSampleWithUid(int32_t uid, float sample) const; + private: const int64_t mMetricIdHash; const std::shared_ptr mBinOptions;