@@ -49,34 +49,38 @@ public interface ApiTracer {
49
49
* between clients using gax and external resources to share the same implementation of the
50
50
* tracing. For example OpenCensus will install a thread local that can read by the GRPC.
51
51
*/
52
- Scope inScope ();
52
+ default Scope inScope () {
53
+ return () -> {
54
+ // noop
55
+ };
56
+ };
53
57
54
58
/**
55
59
* Signals that the overall operation has finished successfully. The tracer is now considered
56
60
* closed and should no longer be used.
57
61
*/
58
- void operationSucceeded ();
62
+ default void operationSucceeded () {} ;
59
63
60
64
/**
61
65
* Signals that the operation was cancelled by the user. The tracer is now considered closed and
62
66
* should no longer be used.
63
67
*/
64
- void operationCancelled ();
68
+ default void operationCancelled () {} ;
65
69
66
70
/**
67
71
* Signals that the overall operation has failed and no further attempts will be made. The tracer
68
72
* is now considered closed and should no longer be used.
69
73
*
70
74
* @param error the final error that caused the operation to fail.
71
75
*/
72
- void operationFailed (Throwable error );
76
+ default void operationFailed (Throwable error ) {} ;
73
77
74
78
/**
75
79
* Annotates the operation with selected connection id from the {@code ChannelPool}.
76
80
*
77
81
* @param id the local connection identifier of the selected connection.
78
82
*/
79
- void connectionSelected (String id );
83
+ default void connectionSelected (String id ) {} ;
80
84
81
85
/**
82
86
* Adds an annotation that an attempt is about to start. In general this should occur at the very
@@ -86,7 +90,7 @@ public interface ApiTracer {
86
90
* @deprecated Please use {@link #attemptStarted(Object, int)} instead.
87
91
*/
88
92
@ Deprecated
89
- void attemptStarted (int attemptNumber );
93
+ default void attemptStarted (int attemptNumber ) {} ;
90
94
91
95
/**
92
96
* Adds an annotation that an attempt is about to start with additional information from the
@@ -96,64 +100,64 @@ public interface ApiTracer {
96
100
* @param attemptNumber the zero based sequential attempt number.
97
101
* @param request request of this attempt.
98
102
*/
99
- void attemptStarted (Object request , int attemptNumber );
103
+ default void attemptStarted (Object request , int attemptNumber ) {} ;
100
104
101
105
/** Adds an annotation that the attempt succeeded. */
102
- void attemptSucceeded ();
106
+ default void attemptSucceeded () {} ;
103
107
104
108
/** Add an annotation that the attempt was cancelled by the user. */
105
- void attemptCancelled ();
109
+ default void attemptCancelled () {} ;
106
110
107
111
/**
108
112
* Adds an annotation that the attempt failed, but another attempt will be made after the delay.
109
113
*
110
114
* @param error the transient error that caused the attempt to fail.
111
115
* @param delay the amount of time to wait before the next attempt will start.
112
116
*/
113
- void attemptFailed (Throwable error , Duration delay );
117
+ default void attemptFailed (Throwable error , Duration delay ) {} ;
114
118
115
119
/**
116
120
* Adds an annotation that the attempt failed and that no further attempts will be made because
117
121
* retry limits have been reached.
118
122
*
119
123
* @param error the last error received before retries were exhausted.
120
124
*/
121
- void attemptFailedRetriesExhausted (Throwable error );
125
+ default void attemptFailedRetriesExhausted (Throwable error ) {} ;
122
126
123
127
/**
124
128
* Adds an annotation that the attempt failed and that no further attempts will be made because
125
129
* the last error was not retryable.
126
130
*
127
131
* @param error the error that caused the final attempt to fail.
128
132
*/
129
- void attemptPermanentFailure (Throwable error );
133
+ default void attemptPermanentFailure (Throwable error ) {} ;
130
134
131
135
/**
132
136
* Signals that the initial RPC for the long running operation failed.
133
137
*
134
138
* @param error the error that caused the long running operation fail.
135
139
*/
136
- void lroStartFailed (Throwable error );
140
+ default void lroStartFailed (Throwable error ) {} ;
137
141
138
142
/**
139
143
* Signals that the initial RPC successfully started the long running operation. The long running
140
144
* operation will now be polled for completion.
141
145
*/
142
- void lroStartSucceeded ();
146
+ default void lroStartSucceeded () {} ;
143
147
144
148
/** Adds an annotation that a streaming response has been received. */
145
- void responseReceived ();
149
+ default void responseReceived () {} ;
146
150
147
151
/** Adds an annotation that a streaming request has been sent. */
148
- void requestSent ();
152
+ default void requestSent () {} ;
149
153
150
154
/**
151
155
* Adds an annotation that a batch of writes has been flushed.
152
156
*
153
157
* @param elementCount the number of elements in the batch.
154
158
* @param requestSize the size of the batch in bytes.
155
159
*/
156
- void batchRequestSent (long elementCount , long requestSize );
160
+ default void batchRequestSent (long elementCount , long requestSize ) {} ;
157
161
158
162
/**
159
163
* A context class to be used with {@link #inScope()} and a try-with-resources block. Closing a
0 commit comments