Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
add more sensible bucket boundaries for retry per call histograms
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenziestarr committed Jan 5, 2022
1 parent d33b703 commit 1c7d888
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
Expand Up @@ -134,6 +134,10 @@ public final class RpcViewConstants {
0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0,
4096.0, 8192.0, 16384.0, 32768.0, 65536.0));

@VisibleForTesting
static final List<Double> RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES =
Collections.unmodifiableList(Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 100.0, 1000.0));

// Use Aggregation.Mean to record sum and count stats at the same time.
@VisibleForTesting static final Aggregation MEAN = Aggregation.Mean.create();
@VisibleForTesting static final Aggregation COUNT = Count.create();
Expand All @@ -154,6 +158,10 @@ public final class RpcViewConstants {
static final Aggregation AGGREGATION_WITH_COUNT_HISTOGRAM =
Distribution.create(BucketBoundaries.create(RPC_COUNT_BUCKET_BOUNDARIES));

@VisibleForTesting
static final Aggregation AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM =
Distribution.create(BucketBoundaries.create(RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES));

@VisibleForTesting static final Duration MINUTE = Duration.create(60, 0);
@VisibleForTesting static final Duration HOUR = Duration.create(60 * 60, 0);

Expand Down Expand Up @@ -515,7 +523,7 @@ public final class RpcViewConstants {
View.Name.create("grpc.io/client/retries_per_call"),
"Number of client retries per call",
GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL,
AGGREGATION_WITH_COUNT_HISTOGRAM,
AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM,
Arrays.asList(GRPC_CLIENT_METHOD));

/**
Expand All @@ -524,51 +532,51 @@ public final class RpcViewConstants {
* @since 0.28
*/
public static final View GRPC_CLIENT_TRANSPARENT_RETRIES_VIEW =
View.create(
View.Name.create("grpc.io/client/transparent_retries"),
"Total number of transparent client retries across calls",
GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL,
SUM,
Arrays.asList(GRPC_CLIENT_METHOD));
View.create(
View.Name.create("grpc.io/client/transparent_retries"),
"Total number of transparent client retries across calls",
GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL,
SUM,
Arrays.asList(GRPC_CLIENT_METHOD));

/**
* {@link View} for total time of delay while there is no active attempt during the client call.
*
* @since 0.28
*/
public static final View GRPC_CLIENT_RETRY_DELAY_PER_CALL_VIEW =
View.create(
View.Name.create("grpc.io/client/retry_delay_per_call"),
"Total time of delay while there is no active attempt during the client call",
GRPC_CLIENT_RETRY_DELAY_PER_CALL,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
Arrays.asList(GRPC_CLIENT_METHOD));
View.create(
View.Name.create("grpc.io/client/retry_delay_per_call"),
"Total time of delay while there is no active attempt during the client call",
GRPC_CLIENT_RETRY_DELAY_PER_CALL,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
Arrays.asList(GRPC_CLIENT_METHOD));

/**
* {@link View} for total retries across all calls, excluding transparent retries.
*
* @since 0.28
*/
public static final View GRPC_CLIENT_RETRIES_VIEW =
View.create(
View.Name.create("grpc.io/client/retries"),
"Total number of client retries across all calls",
GRPC_CLIENT_RETRIES_PER_CALL,
SUM,
Arrays.asList(GRPC_CLIENT_METHOD));
View.create(
View.Name.create("grpc.io/client/retries"),
"Total number of client retries across all calls",
GRPC_CLIENT_RETRIES_PER_CALL,
SUM,
Arrays.asList(GRPC_CLIENT_METHOD));

/**
* {@link View} for transparent retries per call.
*
* @since 0.28
*/
public static final View GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL_VIEW =
View.create(
View.Name.create("grpc.io/client/transparent_retries_per_call"),
"Number of transparent client retries per call",
GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL,
AGGREGATION_WITH_COUNT_HISTOGRAM,
Arrays.asList(GRPC_CLIENT_METHOD));
View.create(
View.Name.create("grpc.io/client/transparent_retries_per_call"),
"Number of transparent client retries per call",
GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL,
AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM,
Arrays.asList(GRPC_CLIENT_METHOD));

// Rpc server cumulative views.

Expand Down
Expand Up @@ -146,12 +146,12 @@ public final class RpcViews {

@VisibleForTesting
static final ImmutableSet<View> GRPC_CLIENT_RETRY_VIEWS_SET =
ImmutableSet.of(
RpcViewConstants.GRPC_CLIENT_RETRIES_PER_CALL_VIEW,
RpcViewConstants.GRPC_CLIENT_RETRIES_VIEW,
RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL_VIEW,
RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_VIEW,
RpcViewConstants.GRPC_CLIENT_RETRY_DELAY_PER_CALL_VIEW);
ImmutableSet.of(
RpcViewConstants.GRPC_CLIENT_RETRIES_PER_CALL_VIEW,
RpcViewConstants.GRPC_CLIENT_RETRIES_VIEW,
RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_PER_CALL_VIEW,
RpcViewConstants.GRPC_CLIENT_TRANSPARENT_RETRIES_VIEW,
RpcViewConstants.GRPC_CLIENT_RETRY_DELAY_PER_CALL_VIEW);

@VisibleForTesting
static final ImmutableSet<View> GRPC_SERVER_BASIC_VIEWS_SET =
Expand Down
Expand Up @@ -66,6 +66,9 @@ public void testConstants() {
0.0, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0,
8192.0, 16384.0, 32768.0, 65536.0)
.inOrder();
assertThat(RpcViewConstants.RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES)
.containsExactly(1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 100.0, 1000.0)
.inOrder();

// Test Aggregations
assertThat(RpcViewConstants.MEAN).isEqualTo(Mean.create());
Expand All @@ -82,7 +85,10 @@ public void testConstants() {
.isEqualTo(
Distribution.create(
BucketBoundaries.create(RpcViewConstants.RPC_COUNT_BUCKET_BOUNDARIES)));

assertThat(RpcViewConstants.AGGREGATION_WITH_COUNT_RETRY_HISTOGRAM)
.isEqualTo(
Distribution.create(
BucketBoundaries.create(RpcViewConstants.RETRY_COUNT_PER_CALL_BUCKET_BOUNDARIES)));
// Test Duration and Window
assertThat(RpcViewConstants.MINUTE).isEqualTo(Duration.create(60, 0));
assertThat(RpcViewConstants.HOUR).isEqualTo(Duration.create(60 * 60, 0));
Expand Down
Expand Up @@ -88,7 +88,7 @@ public void registerClientRetryGrpcViews() {
FakeViewManager fakeViewManager = new FakeViewManager();
RpcViews.registerClientRetryGrpcViews(fakeViewManager);
assertThat(fakeViewManager.getRegisteredViews())
.containsExactlyElementsIn(RpcViews.GRPC_CLIENT_RETRY_VIEWS_SET);
.containsExactlyElementsIn(RpcViews.GRPC_CLIENT_RETRY_VIEWS_SET);
}

@Test
Expand Down

0 comments on commit 1c7d888

Please sign in to comment.