3030import com .google .aggregate .adtech .worker .Annotations .EnablePrivacyBudgetKeyFiltering ;
3131import com .google .aggregate .adtech .worker .Annotations .EnableStackTraceInResponse ;
3232import com .google .aggregate .adtech .worker .Annotations .EnableThresholding ;
33+ import com .google .aggregate .adtech .worker .Annotations .InstanceId ;
3334import com .google .aggregate .adtech .worker .Annotations .MaxDepthOfStackTrace ;
3435import com .google .aggregate .adtech .worker .Annotations .NonBlockingThreadPool ;
3536import com .google .aggregate .adtech .worker .Annotations .OutputShardFileSizeBytes ;
6970import com .google .inject .Provides ;
7071import com .google .inject .TypeLiteral ;
7172import com .google .inject .multibindings .OptionalBinder ;
73+ import com .google .privacysandbox .otel .Annotations .EnableOTelLogs ;
7274import com .google .privacysandbox .otel .Annotations .GrpcOtelCollectorEndpoint ;
7375import com .google .scp .operator .cpio .blobstorageclient .aws .S3BlobStorageClientModule .S3EndpointOverrideBinding ;
7476import com .google .scp .operator .cpio .blobstorageclient .aws .S3BlobStorageClientModule .S3UsePartialRequests ;
121123import javax .inject .Singleton ;
122124import software .amazon .awssdk .http .SdkHttpClient ;
123125import software .amazon .awssdk .http .apache .ApacheHttpClient ;
126+ import software .amazon .awssdk .regions .internal .util .EC2MetadataUtils ;
124127
125128public final class AggregationWorkerModule extends AbstractModule {
126129
@@ -324,8 +327,8 @@ protected void configure() {
324327
325328 // Parameter to set exception cache. This is a test only flag.
326329 bind (Long .class )
327- .annotatedWith (ExceptionCacheEntryTtlSec .class )
328- .toInstance (args .getExceptionCacheEntryTtlSec ());
330+ .annotatedWith (ExceptionCacheEntryTtlSec .class )
331+ .toInstance (args .getExceptionCacheEntryTtlSec ());
329332
330333 // Dependencies for privacy budgeting.
331334 bind (PrivacyBudgetingServiceBridge .class ).to (args .getPrivacyBudgeting ().getBridge ());
@@ -381,17 +384,19 @@ protected void configure() {
381384
382385 // Otel exporter.
383386 switch (args .getOTelExporterSelector ()) {
384- // Specifying CollectorEndpoint is required for GRPC exporter because aggregation service
385- // would send metric to the CollectorEndpoint and thus collector/exporter could collect.
387+ // Specifying CollectorEndpoint is required for GRPC exporter because aggregation service
388+ // would send metric to the CollectorEndpoint and thus collector/exporter could collect.
386389 case GRPC :
387390 bind (String .class )
388391 .annotatedWith (GrpcOtelCollectorEndpoint .class )
389392 .toInstance (args .getGrpcCollectorEndpoint ());
390393 break ;
391- default :
394+ // No need to bind anything for JSON.
395+ case JSON :
392396 break ;
393397 }
394398 install (args .getOTelExporterSelector ().getOTelConfigurationModule ());
399+ bind (boolean .class ).annotatedWith (EnableOTelLogs .class ).toInstance (args .isOTelLogsEnabled ());
395400
396401 // Response related flags.
397402 bind (boolean .class )
@@ -457,7 +462,6 @@ Supplier<ImmutableMap<String, String>> providesLocalFileJobParameters() {
457462 @ Singleton
458463 @ NonBlockingThreadPool
459464 ListeningExecutorService provideNonBlockingThreadPool () {
460- // TODO(b/281572881): Investigate on optimal value for nonBlockingThreadPool size.
461465 return MoreExecutors .listeningDecorator (
462466 Executors .newFixedThreadPool (args .getNonBlockingThreadPoolSize ()));
463467 }
@@ -466,7 +470,6 @@ ListeningExecutorService provideNonBlockingThreadPool() {
466470 @ Singleton
467471 @ BlockingThreadPool
468472 ListeningExecutorService provideBlockingThreadPool () {
469- // TODO(b/281572881): Investigate on optimal value for blockingThreadPool size.
470473 return MoreExecutors .listeningDecorator (
471474 Executors .newFixedThreadPool (args .getBlockingThreadPoolSize ()));
472475 }
@@ -477,4 +480,13 @@ ListeningExecutorService provideBlockingThreadPool() {
477480 ListeningExecutorService provideCustomForkJoinThreadPool () {
478481 return MoreExecutors .listeningDecorator (new ForkJoinPool (args .getNonBlockingThreadPoolSize ()));
479482 }
483+
484+ @ Provides
485+ @ InstanceId
486+ String provideInstanceID () {
487+ if (EC2MetadataUtils .getInstanceId () == null ) {
488+ return "" ;
489+ }
490+ return EC2MetadataUtils .getInstanceId ();
491+ }
480492}
0 commit comments