diff options
author | Vova Sharaienko <sharaienko@google.com> | 2023-12-13 18:36:00 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-12-13 18:36:00 +0000 |
commit | 36c0b3e34f352a51b7dfb4217fb5cd050d90c2a2 (patch) | |
tree | 84f421f4b4695d671fe5998912b80dec077f31f3 /java/com | |
parent | 1f3f5b4d972543ad965e199a47c60e26b2ba09ca (diff) | |
parent | 7d21b70df8d4ee112323b2ceae487c657359e2e2 (diff) | |
download | modules-utils-36c0b3e34f352a51b7dfb4217fb5cd050d90c2a2.tar.gz |
Merge "[TeX] Removed JNI dependency" into main
Diffstat (limited to 'java/com')
-rw-r--r-- | java/com/android/modules/expresslog/Android.bp | 6 | ||||
-rw-r--r-- | java/com/android/modules/expresslog/Counter.java | 8 | ||||
-rw-r--r-- | java/com/android/modules/expresslog/Histogram.java | 21 | ||||
-rw-r--r-- | java/com/android/modules/expresslog/Utils.java | 21 |
4 files changed, 22 insertions, 34 deletions
diff --git a/java/com/android/modules/expresslog/Android.bp b/java/com/android/modules/expresslog/Android.bp index cacc7f8..59504bd 100644 --- a/java/com/android/modules/expresslog/Android.bp +++ b/java/com/android/modules/expresslog/Android.bp @@ -28,12 +28,16 @@ java_library { libs: [ "framework-statsd", ], + static_libs: [ + "expresslog-catalog", + ], } genrule { name: "statslog-expresslog-java-gen", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen) --java $(out) --module expresslog" + - " --javaPackage com.android.modules.expresslog --javaClass StatsExpressLog", + " --javaPackage com.android.modules.expresslog" + + " --javaClass StatsExpressLog", out: ["com/android/modules/expresslog/StatsExpressLog.java"], } diff --git a/java/com/android/modules/expresslog/Counter.java b/java/com/android/modules/expresslog/Counter.java index b788c3f..bcacb8b 100644 --- a/java/com/android/modules/expresslog/Counter.java +++ b/java/com/android/modules/expresslog/Counter.java @@ -18,8 +18,6 @@ package com.android.modules.expresslog; import android.annotation.NonNull; -import com.android.modules.expresslog.StatsExpressLog; - /** Counter encapsulates StatsD write API calls */ public final class Counter { @@ -49,7 +47,8 @@ public final class Counter { * @param amount to increment counter */ public static void logIncrement(@NonNull String metricId, long amount) { - final long metricIdHash = Utils.hashString(metricId); + final long metricIdHash = + MetricIds.getMetricIdHash(metricId, MetricIds.METRIC_TYPE_COUNTER); StatsExpressLog.write(StatsExpressLog.EXPRESS_EVENT_REPORTED, metricIdHash, amount); } @@ -60,7 +59,8 @@ public final class Counter { * @param amount to increment counter */ public static void logIncrementWithUid(@NonNull String metricId, int uid, long amount) { - final long metricIdHash = Utils.hashString(metricId); + final long metricIdHash = + MetricIds.getMetricIdHash(metricId, MetricIds.METRIC_TYPE_COUNTER_WITH_UID); StatsExpressLog.write( StatsExpressLog.EXPRESS_UID_EVENT_REPORTED, metricIdHash, amount, uid); } diff --git a/java/com/android/modules/expresslog/Histogram.java b/java/com/android/modules/expresslog/Histogram.java index be300bf..4f61c85 100644 --- a/java/com/android/modules/expresslog/Histogram.java +++ b/java/com/android/modules/expresslog/Histogram.java @@ -20,14 +20,12 @@ import android.annotation.FloatRange; import android.annotation.IntRange; import android.annotation.NonNull; -import com.android.modules.expresslog.StatsExpressLog; - import java.util.Arrays; /** Histogram encapsulates StatsD write API calls */ public final class Histogram { - private final long mMetricIdHash; + private final String mMetricId; private final BinOptions mBinOptions; /** @@ -37,7 +35,7 @@ public final class Histogram { * @param binOptions to calculate bin index for samples */ public Histogram(@NonNull String metricId, @NonNull BinOptions binOptions) { - mMetricIdHash = Utils.hashString(metricId); + mMetricId = metricId; mBinOptions = binOptions; } @@ -47,9 +45,10 @@ public final class Histogram { * @param sample value */ public void logSample(float sample) { + final long hash = MetricIds.getMetricIdHash(mMetricId, MetricIds.METRIC_TYPE_HISTOGRAM); final int binIndex = mBinOptions.getBinForSample(sample); - StatsExpressLog.write(StatsExpressLog.EXPRESS_HISTOGRAM_SAMPLE_REPORTED, mMetricIdHash, - /*count*/ 1, binIndex); + StatsExpressLog.write( + StatsExpressLog.EXPRESS_HISTOGRAM_SAMPLE_REPORTED, hash, /*count*/ 1, binIndex); } /** @@ -59,9 +58,15 @@ public final class Histogram { * @param sample value */ public void logSampleWithUid(int uid, float sample) { + final long hash = + MetricIds.getMetricIdHash(mMetricId, MetricIds.METRIC_TYPE_HISTOGRAM_WITH_UID); final int binIndex = mBinOptions.getBinForSample(sample); - StatsExpressLog.write(StatsExpressLog.EXPRESS_UID_HISTOGRAM_SAMPLE_REPORTED, - mMetricIdHash, /*count*/ 1, binIndex, uid); + StatsExpressLog.write( + StatsExpressLog.EXPRESS_UID_HISTOGRAM_SAMPLE_REPORTED, + hash, /*count*/ + 1, + binIndex, + uid); } /** Used by Histogram to map data sample to corresponding bin */ diff --git a/java/com/android/modules/expresslog/Utils.java b/java/com/android/modules/expresslog/Utils.java deleted file mode 100644 index fde90fc..0000000 --- a/java/com/android/modules/expresslog/Utils.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.modules.expresslog; - -final class Utils { - static native long hashString(String stringToHash); -} |