diff options
author | Yang Song <songy23@users.noreply.github.com> | 2018-08-20 16:34:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-20 16:34:51 -0700 |
commit | 2b31689d9a8ea27e5c9204ca034a84d5d776dece (patch) | |
tree | fb65e2d2502b82615ae5fd49e494e9383abf4768 | |
parent | 9a766e451a0ffbc63140ba46abc6dd0227c8563d (diff) | |
download | opencensus-java-2b31689d9a8ea27e5c9204ca034a84d5d776dece.tar.gz |
Make an internal function static. (#1375)
* Make an internal function static.
* Make other functions static too.
-rw-r--r-- | impl_core/src/main/java/io/opencensus/implcore/stats/MetricUtils.java | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/stats/MetricUtils.java b/impl_core/src/main/java/io/opencensus/implcore/stats/MetricUtils.java index b706b0da..cd1e5364 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/stats/MetricUtils.java +++ b/impl_core/src/main/java/io/opencensus/implcore/stats/MetricUtils.java @@ -64,25 +64,17 @@ final class MetricUtils { return aggregation.match( Functions.returnConstant( measure.match( - Functions.returnConstant(Type.CUMULATIVE_DOUBLE), // Sum Double - Functions.returnConstant(Type.CUMULATIVE_INT64), // Sum Int64 - Functions.<Type>throwAssertionError())), - Functions.returnConstant(Type.CUMULATIVE_INT64), // Count - Functions.returnConstant(Type.CUMULATIVE_DISTRIBUTION), // Distribution + TYPE_CUMULATIVE_DOUBLE_FUNCTION, // Sum Double + TYPE_CUMULATIVE_INT64_FUNCTION, // Sum Int64 + TYPE_UNRECOGNIZED_FUNCTION)), + TYPE_CUMULATIVE_INT64_FUNCTION, // Count + TYPE_CUMULATIVE_DISTRIBUTION_FUNCTION, // Distribution Functions.returnConstant( measure.match( - Functions.returnConstant(Type.GAUGE_DOUBLE), // LastValue Double - Functions.returnConstant(Type.GAUGE_INT64), // LastValue Long - Functions.<Type>throwAssertionError())), - new Function<Aggregation, Type>() { - @Override - public Type apply(Aggregation arg) { - if (arg instanceof Aggregation.Mean) { - return Type.CUMULATIVE_DOUBLE; // Mean - } - throw new AssertionError(); - } - }); + TYPE_GAUGE_DOUBLE_FUNCTION, // LastValue Double + TYPE_GAUGE_INT64_FUNCTION, // LastValue Long + TYPE_UNRECOGNIZED_FUNCTION)), + AGGREGATION_TYPE_DEFAULT_FUNCTION); } static List<LabelValue> tagValuesToLabelValues(List</*@Nullable*/ TagValue> tagValues) { @@ -93,5 +85,34 @@ final class MetricUtils { return labelValues; } + private static final Function<Object, Type> TYPE_CUMULATIVE_DOUBLE_FUNCTION = + Functions.returnConstant(Type.CUMULATIVE_DOUBLE); + + private static final Function<Object, Type> TYPE_CUMULATIVE_INT64_FUNCTION = + Functions.returnConstant(Type.CUMULATIVE_INT64); + + private static final Function<Object, Type> TYPE_CUMULATIVE_DISTRIBUTION_FUNCTION = + Functions.returnConstant(Type.CUMULATIVE_DISTRIBUTION); + + private static final Function<Object, Type> TYPE_GAUGE_DOUBLE_FUNCTION = + Functions.returnConstant(Type.GAUGE_DOUBLE); + + private static final Function<Object, Type> TYPE_GAUGE_INT64_FUNCTION = + Functions.returnConstant(Type.GAUGE_INT64); + + private static final Function<Object, Type> TYPE_UNRECOGNIZED_FUNCTION = + Functions.<Type>throwAssertionError(); + + private static final Function<Aggregation, Type> AGGREGATION_TYPE_DEFAULT_FUNCTION = + new Function<Aggregation, Type>() { + @Override + public Type apply(Aggregation arg) { + if (arg instanceof Aggregation.Mean) { + return Type.CUMULATIVE_DOUBLE; // Mean + } + throw new AssertionError(); + } + }; + private MetricUtils() {} } |