1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.car.logging;
18 
19 import android.annotation.FloatRange;
20 import android.annotation.IntRange;
21 
22 import com.android.modules.expresslog.Histogram;
23 
24 /**
25  * Interface for creating a {@link com.android.modules.expresslog.Histogram}.
26  *
27  * This interface allows faking the implementation in unit tests.
28  */
29 public interface HistogramFactoryInterface {
30     /**
31      * Creates a new histogram using uniform (linear) sized bins.
32      *
33      * @param metricId          to log, logging will be no-op if metricId is not defined in the TeX
34      *                          catalog
35      * @param binCount          amount of histogram bins. 2 bin indexes will be calculated
36      *                          automatically to represent underflow & overflow bins
37      * @param minValue          is included in the first bin, values less than minValue
38      *                          go to underflow bin
39      * @param exclusiveMaxValue is included in the overflow bucket. For accurate
40      *                          measure up to kMax, then exclusiveMaxValue
41      *                          should be set to kMax + 1
42      */
newUniformHistogram(String metricId, @IntRange(from = 1) int binCount, float minValue, float exclusiveMaxValue)43     Histogram newUniformHistogram(String metricId, @IntRange(from = 1) int binCount,
44             float minValue, float exclusiveMaxValue);
45 
46     /**
47      * Creates a new histogram using scaled range bins.
48      *
49      * @param metricId      to log, logging will be no-op if metricId is not defined in the TeX
50      *                      catalog
51      * @param binCount      amount of histogram bins. 2 bin indexes will be calculated
52      *                      automatically to represent underflow & overflow bins
53      * @param minValue      is included in the first bin, values less than minValue
54      *                      go to underflow bin
55      * @param firstBinWidth used to represent first bin width and as a reference to calculate
56      *                      width for consecutive bins
57      * @param scaleFactor   used to calculate width for consecutive bins
58      */
newScaledRangeHistogram(String metricId, @IntRange(from = 1) int binCount, int minValue, @FloatRange(from = 1.f) float firstBinWidth, @FloatRange(from = 1.f) float scaleFactor)59     Histogram newScaledRangeHistogram(String metricId, @IntRange(from = 1) int binCount,
60             int minValue, @FloatRange(from = 1.f) float firstBinWidth,
61             @FloatRange(from = 1.f) float scaleFactor);
62 }
63