@@ -35,7 +35,7 @@ const retryOptions = {
35
35
initialRetryTime : 500 ,
36
36
factor : 0.2 ,
37
37
multiplier : 2 ,
38
- retries : 10 ,
38
+ retries : 5 ,
39
39
} satisfies RetryOptions ; // why satisfies? To be able to use `retryOptions.retries` and get `number` instead of `number | undefined`
40
40
41
41
export function splitReport ( report : RawReport , numOfChunks : number ) {
@@ -165,7 +165,7 @@ export function createUsage(config: {
165
165
return Object . keys ( report . map ) . length ;
166
166
} ,
167
167
split ( report , numOfChunks ) {
168
- logger . info ( 'Splitting into %s' , numOfChunks ) ;
168
+ logger . info ( 'Splitting report into %s (id=%s) ' , numOfChunks , report . id ) ;
169
169
return splitReport ( report , numOfChunks ) ;
170
170
} ,
171
171
onRetry ( reports ) {
@@ -212,21 +212,15 @@ export function createUsage(config: {
212
212
rawOperationWrites . inc ( numOfOperations ) ;
213
213
logger . info ( `Flushed (id=%s, operations=%s)` , batchId , numOfOperations ) ;
214
214
}
215
-
216
- changeStatus ( Status . Ready ) ;
217
215
} catch ( error : any ) {
218
216
rawOperationFailures . inc ( numOfOperations ) ;
219
217
220
218
changeStatus ( Status . Unhealthy ) ;
221
- logger . error ( `Failed to flush (id=%s, error=%s)` , batchId , error . message ) ;
222
- Sentry . setTags ( {
219
+ logger . error (
220
+ `Failed to flush. Adding to fallback queue (id=%s, error=%s)` ,
223
221
batchId ,
224
- message : error . message ,
225
- numOfOperations,
226
- } ) ;
227
- Sentry . captureException ( error ) ;
228
-
229
- logger . info ( 'Adding to fallback queue (id=%s)' , batchId ) ;
222
+ error . message ,
223
+ ) ;
230
224
fallback . add ( value , numOfOperations ) ;
231
225
232
226
throw error ;
@@ -255,6 +249,11 @@ export function createUsage(config: {
255
249
} finally {
256
250
stopTimer ( ) ;
257
251
}
252
+
253
+ if ( fallback . size ( ) === 0 ) {
254
+ logger . info ( 'Fallback queue flushed' ) ;
255
+ changeStatus ( Status . Ready ) ;
256
+ }
258
257
} ,
259
258
logger : logger . child ( { component : 'fallback' } ) ,
260
259
} ) ;
@@ -306,7 +305,7 @@ export function createUsage(config: {
306
305
} ,
307
306
) ,
308
307
readiness ( ) {
309
- return status === Status . Ready && fallback . size ( ) === 0 ;
308
+ return status === Status . Ready ;
310
309
} ,
311
310
async start ( ) {
312
311
logger . info ( 'Starting Kafka producer' ) ;
0 commit comments