aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorYang Song <songy23@users.noreply.github.com>2018-02-12 12:47:35 -0800
committerGitHub <noreply@github.com>2018-02-12 12:47:35 -0800
commit0ddaa44ab021edab57c9156b002fb5c3f7b28309 (patch)
treec6cf709740891fa99cc2e2d7a130ebd71e83872f /contrib
parent2c3886070669632a10c3a6fbd45420581a6f0fd8 (diff)
downloadplatform_external_opencensus-java-0ddaa44ab021edab57c9156b002fb5c3f7b28309.tar.gz
platform_external_opencensus-java-0ddaa44ab021edab57c9156b002fb5c3f7b28309.tar.bz2
platform_external_opencensus-java-0ddaa44ab021edab57c9156b002fb5c3f7b28309.zip
Add cumulative views for started and finished RPCs. (#993)
* Add cumulative views for started and finished RPCs. * Update started/finished count views to use COUNT aggregation
Diffstat (limited to 'contrib')
-rw-r--r--contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java74
-rw-r--r--contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java6
-rw-r--r--contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java2
3 files changed, 73 insertions, 9 deletions
diff --git a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java
index 6ac71e8f..b643c3dd 100644
--- a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java
+++ b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViewConstants.java
@@ -44,6 +44,7 @@ import static io.opencensus.contrib.grpc.metrics.RpcMeasureConstants.RPC_STATUS;
import com.google.common.annotations.VisibleForTesting;
import io.opencensus.common.Duration;
import io.opencensus.stats.Aggregation;
+import io.opencensus.stats.Aggregation.Count;
import io.opencensus.stats.Aggregation.Distribution;
import io.opencensus.stats.Aggregation.Mean;
import io.opencensus.stats.BucketBoundaries;
@@ -101,6 +102,7 @@ public final class RpcViewConstants {
// Use Aggregation.Mean to record sum and count stats at the same time.
@VisibleForTesting static final Aggregation MEAN = Mean.create();
+ @VisibleForTesting static final Aggregation COUNT = Count.create();
@VisibleForTesting
static final Aggregation AGGREGATION_WITH_BYTES_HISTOGRAM =
@@ -248,6 +250,34 @@ public final class RpcViewConstants {
Arrays.asList(RPC_METHOD),
CUMULATIVE);
+ /**
+ * Cumulative {@link View} for started client RPCs.
+ *
+ * @since 0.12
+ */
+ public static final View RPC_CLIENT_STARTED_COUNT_CUMULATIVE_VIEW =
+ View.create(
+ View.Name.create("grpc.io/client/started_count/cumulative"),
+ "Number of started client RPCs",
+ RPC_CLIENT_STARTED_COUNT,
+ COUNT,
+ Arrays.asList(RPC_METHOD),
+ CUMULATIVE);
+
+ /**
+ * Cumulative {@link View} for finished client RPCs.
+ *
+ * @since 0.12
+ */
+ public static final View RPC_CLIENT_FINISHED_COUNT_CUMULATIVE_VIEW =
+ View.create(
+ View.Name.create("grpc.io/client/finished_count/cumulative"),
+ "Number of finished client RPCs",
+ RPC_CLIENT_FINISHED_COUNT,
+ COUNT,
+ Arrays.asList(RPC_METHOD),
+ CUMULATIVE);
+
// Rpc server cumulative views.
/**
@@ -376,6 +406,34 @@ public final class RpcViewConstants {
Arrays.asList(RPC_METHOD),
CUMULATIVE);
+ /**
+ * Cumulative {@link View} for started server RPCs.
+ *
+ * @since 0.12
+ */
+ public static final View RPC_SERVER_STARTED_COUNT_CUMULATIVE_VIEW =
+ View.create(
+ View.Name.create("grpc.io/server/started_count/cumulative"),
+ "Number of started server RPCs",
+ RPC_SERVER_STARTED_COUNT,
+ COUNT,
+ Arrays.asList(RPC_METHOD),
+ CUMULATIVE);
+
+ /**
+ * Cumulative {@link View} for finished server RPCs.
+ *
+ * @since 0.12
+ */
+ public static final View RPC_SERVER_FINISHED_COUNT_CUMULATIVE_VIEW =
+ View.create(
+ View.Name.create("grpc.io/server/finished_count/cumulative"),
+ "Number of finished server RPCs",
+ RPC_SERVER_FINISHED_COUNT,
+ COUNT,
+ Arrays.asList(RPC_METHOD),
+ CUMULATIVE);
+
// Interval Stats
// RPC client interval views.
@@ -488,7 +546,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/client/started_count/minute"),
"Minute stats on the number of client RPCs started",
RPC_CLIENT_STARTED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_MINUTE);
@@ -502,7 +560,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/client/finished_count/minute"),
"Minute stats on the number of client RPCs finished",
RPC_CLIENT_FINISHED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_MINUTE);
@@ -642,7 +700,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/client/started_count/hour"),
"Hour stats on the number of client RPCs started",
RPC_CLIENT_STARTED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_HOUR);
@@ -656,7 +714,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/client/finished_count/hour"),
"Hour stats on the number of client RPCs finished",
RPC_CLIENT_FINISHED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_HOUR);
@@ -798,7 +856,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/server/started_count/minute"),
"Minute stats on the number of server RPCs started",
RPC_SERVER_STARTED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_MINUTE);
@@ -812,7 +870,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/server/finished_count/minute"),
"Minute stats on the number of server RPCs finished",
RPC_SERVER_FINISHED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_MINUTE);
@@ -952,7 +1010,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/server/started_count/hour"),
"Hour stats on the number of server RPCs started",
RPC_SERVER_STARTED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_HOUR);
@@ -966,7 +1024,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/server/finished_count/hour"),
"Hour stats on the number of server RPCs finished",
RPC_SERVER_FINISHED_COUNT,
- MEAN,
+ COUNT,
Arrays.asList(RPC_METHOD),
INTERVAL_HOUR);
diff --git a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java
index eff15dd3..f0bb8bf5 100644
--- a/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java
+++ b/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java
@@ -40,6 +40,8 @@ public final class RpcViews {
RpcViewConstants.RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES_VIEW,
RpcViewConstants.RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES_VIEW,
RpcViewConstants.RPC_CLIENT_SERVER_ELAPSED_TIME_VIEW,
+ RpcViewConstants.RPC_CLIENT_STARTED_COUNT_CUMULATIVE_VIEW,
+ RpcViewConstants.RPC_CLIENT_FINISHED_COUNT_CUMULATIVE_VIEW,
RpcViewConstants.RPC_SERVER_ERROR_COUNT_VIEW,
RpcViewConstants.RPC_SERVER_SERVER_LATENCY_VIEW,
RpcViewConstants.RPC_SERVER_SERVER_ELAPSED_TIME_VIEW,
@@ -48,7 +50,9 @@ public final class RpcViews {
RpcViewConstants.RPC_SERVER_REQUEST_COUNT_VIEW,
RpcViewConstants.RPC_SERVER_RESPONSE_COUNT_VIEW,
RpcViewConstants.RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES_VIEW,
- RpcViewConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES_VIEW);
+ RpcViewConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES_VIEW,
+ RpcViewConstants.RPC_SERVER_STARTED_COUNT_CUMULATIVE_VIEW,
+ RpcViewConstants.RPC_SERVER_FINISHED_COUNT_CUMULATIVE_VIEW);
@VisibleForTesting
static final ImmutableSet<View> RPC_INTERVAL_VIEWS_SET =
diff --git a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java
index b226d326..76b0b1a2 100644
--- a/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java
+++ b/contrib/grpc_metrics/src/test/java/io/opencensus/contrib/grpc/metrics/RpcViewConstantsTest.java
@@ -19,6 +19,7 @@ package io.opencensus.contrib.grpc.metrics;
import static com.google.common.truth.Truth.assertThat;
import io.opencensus.common.Duration;
+import io.opencensus.stats.Aggregation.Count;
import io.opencensus.stats.Aggregation.Distribution;
import io.opencensus.stats.Aggregation.Mean;
import io.opencensus.stats.BucketBoundaries;
@@ -67,6 +68,7 @@ public final class RpcViewConstantsTest {
// Test Aggregations
assertThat(RpcViewConstants.MEAN).isEqualTo(Mean.create());
+ assertThat(RpcViewConstants.COUNT).isEqualTo(Count.create());
assertThat(RpcViewConstants.AGGREGATION_WITH_BYTES_HISTOGRAM)
.isEqualTo(
Distribution.create(