1717
1818import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .APPLICATION_BLOCKING_LATENCIES_NAME ;
1919import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .APPLIED_KEY ;
20+ import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .APP_PROFILE_KEY ;
2021import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .ATTEMPT_LATENCIES_NAME ;
2122import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .BATCH_WRITE_FLOW_CONTROL_FACTOR_NAME ;
2223import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME ;
24+ import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .BIGTABLE_PROJECT_ID_KEY ;
2325import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .CLIENT_BLOCKING_LATENCIES_NAME ;
2426import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .CLIENT_NAME_KEY ;
2527import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .CLUSTER_ID_KEY ;
2628import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .CONNECTIVITY_ERROR_COUNT_NAME ;
2729import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .FIRST_RESPONSE_LATENCIES_NAME ;
30+ import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .INSTANCE_ID_KEY ;
2831import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .METHOD_KEY ;
2932import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .OPERATION_LATENCIES_NAME ;
3033import static com .google .cloud .bigtable .data .v2 .stub .metrics .BuiltinMetricsConstants .REMAINING_DEADLINE_NAME ;
@@ -832,7 +835,13 @@ public void testBatchWriteFlowControlTargetQpsIncreased() throws InterruptedExce
832835
833836 MetricData targetQpsMetric =
834837 getMetricData (metricReader , BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME );
835- Attributes targetQpsAttributes = Attributes .of (METHOD_KEY , "Bigtable.MutateRows" );
838+ Attributes targetQpsAttributes =
839+ Attributes .builder ()
840+ .put (METHOD_KEY , "Bigtable.MutateRows" )
841+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
842+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
843+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
844+ .build ();
836845 double actual_qps = getAggregatedDoubleValue (targetQpsMetric , targetQpsAttributes );
837846 double expected_qps = 12 ;
838847 assertThat (expected_qps ).isEqualTo (actual_qps );
@@ -843,6 +852,9 @@ public void testBatchWriteFlowControlTargetQpsIncreased() throws InterruptedExce
843852 .put (METHOD_KEY , "Bigtable.MutateRows" )
844853 .put (APPLIED_KEY , true )
845854 .put (STATUS_KEY , "OK" )
855+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
856+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
857+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
846858 .build ();
847859 double actual_factor_mean = getAggregatedDoubleValue (factorMetric , factorAttributes );
848860 double expected_factor_mean = 1.2 ;
@@ -862,7 +874,12 @@ public void testBatchWriteFlowControlTargetQpsDecreased() throws InterruptedExce
862874 MetricData targetQpsMetric =
863875 getMetricData (metricReader , BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME );
864876 Attributes targetQpsAttributes =
865- Attributes .builder ().put (METHOD_KEY , "Bigtable.MutateRows" ).build ();
877+ Attributes .builder ()
878+ .put (METHOD_KEY , "Bigtable.MutateRows" )
879+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
880+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
881+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
882+ .build ();
866883 double actual_qps = getAggregatedDoubleValue (targetQpsMetric , targetQpsAttributes );
867884 double expected_qps = 8.0 ;
868885 assertThat (expected_qps ).isEqualTo (actual_qps );
@@ -873,6 +890,9 @@ public void testBatchWriteFlowControlTargetQpsDecreased() throws InterruptedExce
873890 .put (METHOD_KEY , "Bigtable.MutateRows" )
874891 .put (APPLIED_KEY , true )
875892 .put (STATUS_KEY , "OK" )
893+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
894+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
895+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
876896 .build ();
877897 double actual_factor_mean = getAggregatedDoubleValue (factorMetric , factorAttributes );
878898 double expected_factor_mean = 0.8 ;
@@ -892,7 +912,12 @@ public void testBatchWriteFlowControlTargetQpsCappedOnMaxFactor() throws Interru
892912 MetricData targetQpsMetric =
893913 getMetricData (metricReader , BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME );
894914 Attributes targetQpsAttributes =
895- Attributes .builder ().put (METHOD_KEY , "Bigtable.MutateRows" ).build ();
915+ Attributes .builder ()
916+ .put (METHOD_KEY , "Bigtable.MutateRows" )
917+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
918+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
919+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
920+ .build ();
896921 double actual_qps = getAggregatedDoubleValue (targetQpsMetric , targetQpsAttributes );
897922 // Factor is 1.8 but capped at 1.3 so updated QPS is 13.
898923 double expected_qps = 13 ;
@@ -904,6 +929,9 @@ public void testBatchWriteFlowControlTargetQpsCappedOnMaxFactor() throws Interru
904929 .put (METHOD_KEY , "Bigtable.MutateRows" )
905930 .put (APPLIED_KEY , true )
906931 .put (STATUS_KEY , "OK" )
932+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
933+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
934+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
907935 .build ();
908936 double actual_factor_mean = getAggregatedDoubleValue (factorMetric , factorAttributes );
909937 // Factor is 1.8 but capped at 1.3
@@ -924,7 +952,12 @@ public void testBatchWriteFlowControlTargetQpsCappedOnMinFactor() throws Interru
924952 MetricData targetQpsMetric =
925953 getMetricData (metricReader , BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME );
926954 Attributes targetQpsAttributes =
927- Attributes .builder ().put (METHOD_KEY , "Bigtable.MutateRows" ).build ();
955+ Attributes .builder ()
956+ .put (METHOD_KEY , "Bigtable.MutateRows" )
957+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
958+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
959+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
960+ .build ();
928961 double actual_qps = getAggregatedDoubleValue (targetQpsMetric , targetQpsAttributes );
929962 // Factor is 0.5 but capped at 0.7 so updated QPS is 7.
930963 double expected_qps = 7 ;
@@ -936,6 +969,9 @@ public void testBatchWriteFlowControlTargetQpsCappedOnMinFactor() throws Interru
936969 .put (METHOD_KEY , "Bigtable.MutateRows" )
937970 .put (APPLIED_KEY , true )
938971 .put (STATUS_KEY , "OK" )
972+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
973+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
974+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
939975 .build ();
940976 double actual_factor_mean = getAggregatedDoubleValue (factorMetric , factorAttributes );
941977 // Factor is 0.5 but capped at 0.7
@@ -957,7 +993,12 @@ public void testBatchWriteFlowControlTargetQpsDecreasedForError() throws Interru
957993 MetricData targetQpsMetric =
958994 getMetricData (metricReader , BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME );
959995 Attributes targetQpsAttributes =
960- Attributes .builder ().put (METHOD_KEY , "Bigtable.MutateRows" ).build ();
996+ Attributes .builder ()
997+ .put (METHOD_KEY , "Bigtable.MutateRows" )
998+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
999+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
1000+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
1001+ .build ();
9611002 double actual_qps = getAggregatedDoubleValue (targetQpsMetric , targetQpsAttributes );
9621003 // On error, min factor is applied.
9631004 double expected_qps = 7 ;
@@ -969,6 +1010,9 @@ public void testBatchWriteFlowControlTargetQpsDecreasedForError() throws Interru
9691010 .put (METHOD_KEY , "Bigtable.MutateRows" )
9701011 .put (APPLIED_KEY , true )
9711012 .put (STATUS_KEY , "UNAVAILABLE" )
1013+ .put (BIGTABLE_PROJECT_ID_KEY , PROJECT_ID )
1014+ .put (INSTANCE_ID_KEY , INSTANCE_ID )
1015+ .put (APP_PROFILE_KEY , APP_PROFILE_ID )
9721016 .build ();
9731017 double actual_factor_mean = getAggregatedDoubleValue (factorMetric , factorAttributes );
9741018 // On error, min factor is applied.
0 commit comments