|
| 1 | +/* |
| 2 | + * Copyright 2022 Google LLC |
| 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 | + * https://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 | +package com.google.cloud.bigtable.stats; |
| 17 | + |
| 18 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.APPLICATION_LATENCIES; |
| 19 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.APP_PROFILE; |
| 20 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.ATTEMPT_LATENCIES; |
| 21 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CLIENT_NAME; |
| 22 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CLUSTER; |
| 23 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CONNECTIVITY_ERROR_COUNT; |
| 24 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.FIRST_RESPONSE_LATENCIES; |
| 25 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.INSTANCE_ID; |
| 26 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.METHOD; |
| 27 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.OPERATION_LATENCIES; |
| 28 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.PROJECT_ID; |
| 29 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.RETRY_COUNT; |
| 30 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.SERVER_LATENCIES; |
| 31 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.STATUS; |
| 32 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.STREAMING; |
| 33 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.TABLE; |
| 34 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.THROTTLING_LATENCIES; |
| 35 | +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.ZONE; |
| 36 | +import static io.opencensus.stats.Aggregation.Distribution; |
| 37 | +import static io.opencensus.stats.Aggregation.Sum; |
| 38 | + |
| 39 | +import com.google.common.collect.ImmutableList; |
| 40 | +import io.opencensus.stats.Aggregation; |
| 41 | +import io.opencensus.stats.BucketBoundaries; |
| 42 | +import io.opencensus.stats.View; |
| 43 | + |
| 44 | +/** Create built-in metrics views under bigtable.googleapis.com/internal/client namespace */ |
| 45 | +class BuiltinViewConstants { |
| 46 | + private static final Aggregation AGGREGATION_WITH_MILLIS_HISTOGRAM = |
| 47 | + Distribution.create( |
| 48 | + BucketBoundaries.create( |
| 49 | + ImmutableList.of( |
| 50 | + 0.0, 0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0, |
| 51 | + 13.0, 16.0, 20.0, 25.0, 30.0, 40.0, 50.0, 65.0, 80.0, 100.0, 130.0, 160.0, 200.0, |
| 52 | + 250.0, 300.0, 400.0, 500.0, 650.0, 800.0, 1000.0, 2000.0, 5000.0, 10000.0, |
| 53 | + 20000.0, 50000.0, 100000.0))); |
| 54 | + |
| 55 | + private static final Aggregation AGGREGATION_RETRY_COUNT = |
| 56 | + Distribution.create( |
| 57 | + BucketBoundaries.create( |
| 58 | + ImmutableList.of( |
| 59 | + 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, |
| 60 | + 100.0))); |
| 61 | + |
| 62 | + private static final Aggregation AGGREGATION_ERROR_COUNT = Sum.create(); |
| 63 | + |
| 64 | + static final View OPERATION_LATENCIES_VIEW = |
| 65 | + View.create( |
| 66 | + View.Name.create("bigtable.googleapis.com/internal/client/operation_latencies"), |
| 67 | + "Total time until final operation success or failure, including retries and backoff.", |
| 68 | + OPERATION_LATENCIES, |
| 69 | + AGGREGATION_WITH_MILLIS_HISTOGRAM, |
| 70 | + ImmutableList.of( |
| 71 | + PROJECT_ID, |
| 72 | + INSTANCE_ID, |
| 73 | + APP_PROFILE, |
| 74 | + METHOD, |
| 75 | + STREAMING, |
| 76 | + STATUS, |
| 77 | + CLIENT_NAME, |
| 78 | + CLUSTER, |
| 79 | + ZONE, |
| 80 | + TABLE)); |
| 81 | + |
| 82 | + static final View ATTEMPT_LATENCIES_VIEW = |
| 83 | + View.create( |
| 84 | + View.Name.create("bigtable.googleapis.com/internal/client/attempt_latencies"), |
| 85 | + "Client observed latency per RPC attempt.", |
| 86 | + ATTEMPT_LATENCIES, |
| 87 | + AGGREGATION_WITH_MILLIS_HISTOGRAM, |
| 88 | + ImmutableList.of( |
| 89 | + PROJECT_ID, |
| 90 | + INSTANCE_ID, |
| 91 | + APP_PROFILE, |
| 92 | + METHOD, |
| 93 | + STREAMING, |
| 94 | + STATUS, |
| 95 | + CLIENT_NAME, |
| 96 | + CLUSTER, |
| 97 | + ZONE, |
| 98 | + TABLE)); |
| 99 | + |
| 100 | + static final View RETRY_COUNT_VIEW = |
| 101 | + View.create( |
| 102 | + View.Name.create("bigtable.googleapis.com/internal/client/retry_count"), |
| 103 | + "The number of additional RPCs sent after the initial attempt.", |
| 104 | + RETRY_COUNT, |
| 105 | + AGGREGATION_RETRY_COUNT, |
| 106 | + ImmutableList.of( |
| 107 | + PROJECT_ID, |
| 108 | + INSTANCE_ID, |
| 109 | + APP_PROFILE, |
| 110 | + METHOD, |
| 111 | + STATUS, |
| 112 | + CLIENT_NAME, |
| 113 | + CLUSTER, |
| 114 | + ZONE, |
| 115 | + TABLE)); |
| 116 | + |
| 117 | + static final View FIRST_RESPONSE_LATENCIES_VIEW = |
| 118 | + View.create( |
| 119 | + View.Name.create("bigtable.googleapis.com/internal/client/first_response_latencies"), |
| 120 | + "Latency from operation start until the response headers were received. The publishing of the measurement will be delayed until the attempt response has been received.", |
| 121 | + FIRST_RESPONSE_LATENCIES, |
| 122 | + AGGREGATION_WITH_MILLIS_HISTOGRAM, |
| 123 | + ImmutableList.of( |
| 124 | + PROJECT_ID, |
| 125 | + INSTANCE_ID, |
| 126 | + APP_PROFILE, |
| 127 | + METHOD, |
| 128 | + STATUS, |
| 129 | + CLIENT_NAME, |
| 130 | + CLUSTER, |
| 131 | + ZONE, |
| 132 | + TABLE)); |
| 133 | + |
| 134 | + static final View SERVER_LATENCIES_VIEW = |
| 135 | + View.create( |
| 136 | + View.Name.create("bigtable.googleapis.com/internal/client/server_latencies"), |
| 137 | + "The latency measured from the moment that the RPC entered the Google data center until the RPC was completed.", |
| 138 | + SERVER_LATENCIES, |
| 139 | + AGGREGATION_WITH_MILLIS_HISTOGRAM, |
| 140 | + ImmutableList.of( |
| 141 | + PROJECT_ID, |
| 142 | + INSTANCE_ID, |
| 143 | + APP_PROFILE, |
| 144 | + METHOD, |
| 145 | + STATUS, |
| 146 | + STREAMING, |
| 147 | + CLIENT_NAME, |
| 148 | + CLUSTER, |
| 149 | + ZONE, |
| 150 | + TABLE)); |
| 151 | + |
| 152 | + static final View CONNECTIVITY_ERROR_COUNT_VIEW = |
| 153 | + View.create( |
| 154 | + View.Name.create("bigtable.googleapis.com/internal/client/connectivity_error_count"), |
| 155 | + "Number of requests that failed to reach the Google datacenter. (Requests without google response headers).", |
| 156 | + CONNECTIVITY_ERROR_COUNT, |
| 157 | + AGGREGATION_ERROR_COUNT, |
| 158 | + ImmutableList.of( |
| 159 | + PROJECT_ID, |
| 160 | + INSTANCE_ID, |
| 161 | + APP_PROFILE, |
| 162 | + METHOD, |
| 163 | + STATUS, |
| 164 | + CLIENT_NAME, |
| 165 | + CLUSTER, |
| 166 | + ZONE, |
| 167 | + TABLE)); |
| 168 | + |
| 169 | + static final View APPLICATION_LATENCIES_VIEW = |
| 170 | + View.create( |
| 171 | + View.Name.create("bigtable.googleapis.com/internal/client/application_latencies"), |
| 172 | + "The latency of the client application consuming available response data.", |
| 173 | + APPLICATION_LATENCIES, |
| 174 | + AGGREGATION_WITH_MILLIS_HISTOGRAM, |
| 175 | + ImmutableList.of( |
| 176 | + PROJECT_ID, |
| 177 | + INSTANCE_ID, |
| 178 | + APP_PROFILE, |
| 179 | + METHOD, |
| 180 | + STREAMING, |
| 181 | + CLIENT_NAME, |
| 182 | + CLUSTER, |
| 183 | + ZONE, |
| 184 | + TABLE)); |
| 185 | + |
| 186 | + static final View THROTTLING_LATENCIES_VIEW = |
| 187 | + View.create( |
| 188 | + View.Name.create("bigtable.googleapis.com/internal/client/throttling_latencies"), |
| 189 | + "The artificial latency introduced by the client to limit the number of outstanding requests. The publishing of the measurement will be delayed until the attempt trailers have been received.", |
| 190 | + THROTTLING_LATENCIES, |
| 191 | + AGGREGATION_WITH_MILLIS_HISTOGRAM, |
| 192 | + ImmutableList.of( |
| 193 | + PROJECT_ID, INSTANCE_ID, APP_PROFILE, METHOD, CLIENT_NAME, CLUSTER, ZONE, TABLE)); |
| 194 | +} |
0 commit comments