@@ -65,6 +65,9 @@ public class CloudSyncVerticle extends AbstractVerticle {
65
65
private WorkerExecutor uploadExecutor = null ;
66
66
67
67
private boolean isRefreshing = false ;
68
+
69
+ private long optoutTotalStart = 0 ;
70
+ private final Counter optoutFileCounter ;
68
71
69
72
public CloudSyncVerticle (String name , ICloudStorage cloudStorage , ICloudStorage localStorage ,
70
73
ICloudSync cloudSync , JsonObject jsonConfig ) {
@@ -148,6 +151,11 @@ public CloudSyncVerticle(String name, ICloudStorage cloudStorage, ICloudStorage
148
151
.tag ("store" , name )
149
152
.description ("gauge for number of consecutive " + name + " store refresh failures" )
150
153
.register (Metrics .globalRegistry );
154
+
155
+ this .optoutFileCounter = "optout" .equals (name ) ? Counter
156
+ .builder ("uid2_optout_files_downloaded_total" )
157
+ .description ("counter for total optout files downloaded from S3" )
158
+ .register (Metrics .globalRegistry ) : null ;
151
159
}
152
160
153
161
@ Override
@@ -223,6 +231,10 @@ private Future<Void> cloudRefresh() {
223
231
return Future .succeededFuture ();
224
232
}
225
233
234
+ if ("optout" .equals (this .name )) {
235
+ this .optoutTotalStart = System .currentTimeMillis ();
236
+ }
237
+
226
238
Promise <Void > refreshPromise = Promise .promise ();
227
239
this .isRefreshing = true ;
228
240
vertx .<Void >executeBlocking (blockBromise -> {
@@ -233,6 +245,13 @@ private Future<Void> cloudRefresh() {
233
245
return refreshPromise .future ()
234
246
.onComplete (v -> {
235
247
this .isRefreshing = false ;
248
+ if ("optout" .equals (this .name ) && this .optoutTotalStart > 0 ) {
249
+ long totalDuration = System .currentTimeMillis () - this .optoutTotalStart ;
250
+ LOGGER .info ("Optout sync completed in {} ms" , totalDuration );
251
+ Gauge .builder ("uid2_optout_total_sync_duration_ms" , () -> (double ) totalDuration )
252
+ .description ("Total time taken for complete optout sync operation" )
253
+ .register (Metrics .globalRegistry );
254
+ }
236
255
emitRefreshedEvent ();
237
256
});
238
257
}
@@ -373,6 +392,9 @@ private Future<Void> cloudDownloadFile(String s3Path) {
373
392
if (ar .succeeded ()) {
374
393
vertx .eventBus ().publish (this .eventDownloaded , this .cloudSync .toLocalPath (s3Path ));
375
394
this .counterDownloaded .increment ();
395
+ if (optoutFileCounter != null ) {
396
+ optoutFileCounter .increment ();
397
+ }
376
398
LOGGER .info ("S3 download completed: {} in {} ms" , cloudStorage .mask (s3Path ), downloadTimeMs );
377
399
} else {
378
400
this .counterDownloadFailures .increment ();
@@ -391,11 +413,22 @@ private Future<Void> cloudDownloadFile(String s3Path) {
391
413
}
392
414
393
415
private void cloudDownloadBlocking (Promise <Void > promise , String s3Path ) {
416
+ final long fileDownloadStart = System .currentTimeMillis ();
394
417
try {
395
418
String localPath = this .cloudSync .toLocalPath (s3Path );
396
419
try (InputStream cloudInput = this .cloudStorage .download (s3Path )) {
397
420
this .localStorage .upload (cloudInput , localPath );
398
421
}
422
+
423
+ // Log individual file download timing for optout files (avoid logging full path for security)
424
+ if ("optout" .equals (this .name )) {
425
+ final long fileDownloadEnd = System .currentTimeMillis ();
426
+ final long fileDownloadTime = fileDownloadEnd - fileDownloadStart ;
427
+ // Only log filename portion to avoid potential presigned URL exposure
428
+ String fileName = s3Path .substring (s3Path .lastIndexOf ('/' ) + 1 );
429
+ LOGGER .info ("Optout file {} downloaded in {} ms" , fileName , fileDownloadTime );
430
+ }
431
+
399
432
promise .complete ();
400
433
} catch (Exception ex ) {
401
434
// Be careful as the s3Path may contain the pre-signed S3 token, so do not log the whole path
0 commit comments