@@ -94,6 +94,8 @@ public class AwsApplicationSignalsCustomizerProvider
9494 "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" ;
9595 private static final String AWS_XRAY_DAEMON_ADDRESS_CONFIG = "AWS_XRAY_DAEMON_ADDRESS" ;
9696 private static final String DEFAULT_UDP_ENDPOINT = "127.0.0.1:2000" ;
97+ private static final String OTEL_DISABLED_RESOURCE_PROVIDERS_CONFIG =
98+ "otel.java.disabled.resource.providers" ;
9799
98100 // UDP packet can be upto 64KB. To limit the packet size, we limit the exported batch size.
99101 // This is a bit of a magic number, as there is no simple way to tell how many spans can make a
@@ -102,6 +104,7 @@ public class AwsApplicationSignalsCustomizerProvider
102104
103105 public void customize (AutoConfigurationCustomizer autoConfiguration ) {
104106 autoConfiguration .addPropertiesCustomizer (this ::customizeProperties );
107+ autoConfiguration .addPropertiesCustomizer (this ::customizeLambdaEnvProperties );
105108 autoConfiguration .addResourceCustomizer (this ::customizeResource );
106109 autoConfiguration .addSamplerCustomizer (this ::customizeSampler );
107110 autoConfiguration .addTracerProviderCustomizer (this ::customizeTracerProviderBuilder );
@@ -144,6 +147,30 @@ private Map<String, String> customizeProperties(ConfigProperties configProps) {
144147 return Collections .emptyMap ();
145148 }
146149
150+ private Map <String , String > customizeLambdaEnvProperties (ConfigProperties configProperties ) {
151+ if (isLambdaEnvironment ()) {
152+ Map <String , String > propsOverride = new HashMap <>(2 );
153+
154+ // Disable other AWS Resource Providers
155+ List <String > list = configProperties .getList (OTEL_DISABLED_RESOURCE_PROVIDERS_CONFIG );
156+ List <String > disabledResourceProviders = new ArrayList <>(list );
157+ disabledResourceProviders .add (
158+ "io.opentelemetry.contrib.aws.resource.BeanstalkResourceProvider" );
159+ disabledResourceProviders .add ("io.opentelemetry.contrib.aws.resource.Ec2ResourceProvider" );
160+ disabledResourceProviders .add ("io.opentelemetry.contrib.aws.resource.EcsResourceProvider" );
161+ disabledResourceProviders .add ("io.opentelemetry.contrib.aws.resource.EksResourceProvider" );
162+ propsOverride .put (
163+ OTEL_DISABLED_RESOURCE_PROVIDERS_CONFIG , String .join ("," , disabledResourceProviders ));
164+
165+ // Set the max export batch size for BatchSpanProcessors
166+ propsOverride .put (
167+ "otel.bsp.max.export.batch.size" , String .valueOf (LAMBDA_SPAN_EXPORT_BATCH_SIZE ));
168+
169+ return propsOverride ;
170+ }
171+ return Collections .emptyMap ();
172+ }
173+
147174 private Resource customizeResource (Resource resource , ConfigProperties configProps ) {
148175 if (isApplicationSignalsEnabled (configProps )) {
149176 AttributesBuilder builder = Attributes .builder ();
0 commit comments