@@ -40,7 +40,8 @@ public class StatsRecorderWrapper {
4040 private final SpanName spanName ;
4141 private final Map <String , String > statsAttributes ;
4242
43- private MeasureMap measureMap ;
43+ private MeasureMap attemptMeasureMap ;
44+ private MeasureMap operationMeasureMap ;
4445
4546 public StatsRecorderWrapper (
4647 OperationType operationType ,
@@ -54,10 +55,11 @@ public StatsRecorderWrapper(
5455 this .parentContext = tagger .getCurrentTagContext ();
5556 this .statsAttributes = statsAttributes ;
5657
57- this .measureMap = statsRecorder .newMeasureMap ();
58+ this .attemptMeasureMap = statsRecorder .newMeasureMap ();
59+ this .operationMeasureMap = statsRecorder .newMeasureMap ();
5860 }
5961
60- public void record (String status , String tableId , String zone , String cluster ) {
62+ public void recordOperation (String status , String tableId , String zone , String cluster ) {
6163 TagContextBuilder tagCtx =
6264 newTagContextBuilder (tableId , zone , cluster )
6365 .putLocal (BuiltinMeasureConstants .STATUS , TagValue .create (status ));
@@ -66,39 +68,55 @@ public void record(String status, String tableId, String zone, String cluster) {
6668 tagCtx .putLocal (
6769 BuiltinMeasureConstants .STREAMING , TagValue .create (Boolean .toString (isStreaming )));
6870
69- measureMap .record (tagCtx .build ());
71+ operationMeasureMap .record (tagCtx .build ());
72+ // Reinitialize a new map
73+ operationMeasureMap = statsRecorder .newMeasureMap ();
74+ }
75+
76+ public void recordAttempt (String status , String tableId , String zone , String cluster ) {
77+ TagContextBuilder tagCtx =
78+ newTagContextBuilder (tableId , zone , cluster )
79+ .putLocal (BuiltinMeasureConstants .STATUS , TagValue .create (status ));
80+
81+ boolean isStreaming = operationType == OperationType .ServerStreaming ;
82+ tagCtx .putLocal (
83+ BuiltinMeasureConstants .STREAMING , TagValue .create (Boolean .toString (isStreaming )));
84+
85+ attemptMeasureMap .record (tagCtx .build ());
86+ // Reinitialize a new map
87+ attemptMeasureMap = statsRecorder .newMeasureMap ();
7088 }
7189
7290 public void putOperationLatencies (long operationLatency ) {
73- measureMap .put (BuiltinMeasureConstants .OPERATION_LATENCIES , operationLatency );
91+ operationMeasureMap .put (BuiltinMeasureConstants .OPERATION_LATENCIES , operationLatency );
7492 }
7593
7694 public void putAttemptLatencies (long attemptLatency ) {
77- measureMap .put (BuiltinMeasureConstants .ATTEMPT_LATENCIES , attemptLatency );
95+ attemptMeasureMap .put (BuiltinMeasureConstants .ATTEMPT_LATENCIES , attemptLatency );
7896 }
7997
8098 public void putRetryCount (int attemptCount ) {
81- measureMap .put (BuiltinMeasureConstants .RETRY_COUNT , attemptCount );
99+ operationMeasureMap .put (BuiltinMeasureConstants .RETRY_COUNT , attemptCount );
82100 }
83101
84102 public void putApplicationLatencies (long applicationLatency ) {
85- measureMap .put (BuiltinMeasureConstants .APPLICATION_LATENCIES , applicationLatency );
103+ operationMeasureMap .put (BuiltinMeasureConstants .APPLICATION_LATENCIES , applicationLatency );
86104 }
87105
88106 public void putFirstResponseLatencies (long firstResponseLatency ) {
89- measureMap .put (BuiltinMeasureConstants .FIRST_RESPONSE_LATENCIES , firstResponseLatency );
107+ operationMeasureMap .put (BuiltinMeasureConstants .FIRST_RESPONSE_LATENCIES , firstResponseLatency );
90108 }
91109
92110 public void putGfeLatencies (long serverLatency ) {
93- measureMap .put (BuiltinMeasureConstants .SERVER_LATENCIES , serverLatency );
111+ attemptMeasureMap .put (BuiltinMeasureConstants .SERVER_LATENCIES , serverLatency );
94112 }
95113
96114 public void putGfeMissingHeaders (long connectivityErrors ) {
97- measureMap .put (BuiltinMeasureConstants .CONNECTIVITY_ERROR_COUNT , connectivityErrors );
115+ attemptMeasureMap .put (BuiltinMeasureConstants .CONNECTIVITY_ERROR_COUNT , connectivityErrors );
98116 }
99117
100118 public void putBatchRequestThrottled (long throttledTimeMs ) {
101- measureMap .put (BuiltinMeasureConstants .THROTTLING_LATENCIES , throttledTimeMs );
119+ operationMeasureMap .put (BuiltinMeasureConstants .THROTTLING_LATENCIES , throttledTimeMs );
102120 }
103121
104122 private TagContextBuilder newTagContextBuilder (String tableId , String zone , String cluster ) {
0 commit comments