5151import java .util .Set ;
5252import java .util .logging .Level ;
5353import java .util .logging .Logger ;
54- import java .util .regex .Pattern ;
5554
5655/**
5756 * This customizer performs the following customizations:
7170public class AwsApplicationSignalsCustomizerProvider
7271 implements AutoConfigurationCustomizerProvider {
7372 static final String AWS_LAMBDA_FUNCTION_NAME_CONFIG = "AWS_LAMBDA_FUNCTION_NAME" ;
74- private static final String XRAY_OTLP_ENDPOINT_PATTERN =
75- "^https://xray\\ .([a-z0-9-]+)\\ .amazonaws\\ .com/v1/traces$" ;
7673
7774 private static final Duration DEFAULT_METRIC_EXPORT_INTERVAL = Duration .ofMinutes (1 );
7875 private static final Logger logger =
@@ -98,9 +95,6 @@ public class AwsApplicationSignalsCustomizerProvider
9895 private static final String OTEL_JMX_TARGET_SYSTEM_CONFIG = "otel.jmx.target.system" ;
9996 private static final String OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_CONFIG =
10097 "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" ;
101- private static final String OTEL_EXPORTER_HTTP_PROTOBUF_PROTOCOL = "http/protobuf" ;
102- private static final String OTEL_EXPORTER_OTLP_TRACES_PROTOCOL_CONFIG =
103- "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL" ;
10498 private static final String AWS_XRAY_DAEMON_ADDRESS_CONFIG = "AWS_XRAY_DAEMON_ADDRESS" ;
10599 private static final String DEFAULT_UDP_ENDPOINT = "127.0.0.1:2000" ;
106100 private static final String OTEL_DISABLED_RESOURCE_PROVIDERS_CONFIG =
@@ -112,8 +106,6 @@ public class AwsApplicationSignalsCustomizerProvider
112106 // This is a bit of a magic number, as there is no simple way to tell how many spans can make a
113107 // 64KB batch since spans can vary in size.
114108 private static final int LAMBDA_SPAN_EXPORT_BATCH_SIZE = 10 ;
115- private static final boolean isSigV4Enabled =
116- AwsApplicationSignalsCustomizerProvider .isSigV4Enabled ();
117109
118110 public void customize (AutoConfigurationCustomizer autoConfiguration ) {
119111 autoConfiguration .addPropertiesCustomizer (this ::customizeProperties );
@@ -129,37 +121,6 @@ static boolean isLambdaEnvironment() {
129121 return System .getenv (AWS_LAMBDA_FUNCTION_NAME_CONFIG ) != null ;
130122 }
131123
132- static boolean isSigV4Enabled () {
133- String otlpEndpoint = System .getenv (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_CONFIG );
134- boolean isXrayOtlpEndpoint =
135- otlpEndpoint != null
136- && Pattern .compile (XRAY_OTLP_ENDPOINT_PATTERN )
137- .matcher (otlpEndpoint .toLowerCase ())
138- .matches ();
139-
140- if (isXrayOtlpEndpoint ) {
141- logger .log (Level .INFO , "Detected using AWS OTLP XRay Endpoint." );
142-
143- String otlpTracesProtocol = System .getenv (OTEL_EXPORTER_OTLP_TRACES_PROTOCOL_CONFIG );
144-
145- if (otlpTracesProtocol == null
146- || !otlpTracesProtocol .equals (OTEL_EXPORTER_HTTP_PROTOBUF_PROTOCOL )) {
147- logger .info (
148- String .format (
149- "Improper configuration: Please configure your environment variables and export/set %s=%s" ,
150- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL_CONFIG , OTEL_EXPORTER_HTTP_PROTOBUF_PROTOCOL ));
151- return false ;
152- }
153-
154- logger .info (
155- String .format (
156- "Proper configuration detected: Now exporting trace span data to %s" , otlpEndpoint ));
157- return true ;
158- }
159-
160- return false ;
161- }
162-
163124 private boolean isApplicationSignalsEnabled (ConfigProperties configProps ) {
164125 return configProps .getBoolean (
165126 APPLICATION_SIGNALS_ENABLED_CONFIG ,
@@ -260,10 +221,6 @@ private SdkTracerProviderBuilder customizeTracerProviderBuilder(
260221 return tracerProviderBuilder ;
261222 }
262223
263- if (isSigV4Enabled ) {
264- return tracerProviderBuilder ;
265- }
266-
267224 // Construct meterProvider
268225 MetricExporter metricsExporter =
269226 ApplicationSignalsExporterProvider .INSTANCE .createExporter (configProps );
@@ -330,15 +287,6 @@ private SpanExporter customizeSpanExporter(
330287 }
331288 }
332289
333- // When running OTLP endpoint for X-Ray backend, use custom exporter for SigV4 authentication.
334- if (isSigV4Enabled ) {
335- return new OtlpAwsSpanExporter (
336- (OtlpHttpSpanExporter )
337- spanExporter , // can cast here since we've checked that the environment variable is
338- // set to http/protobuf
339- System .getenv (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_CONFIG ));
340- }
341-
342290 if (isApplicationSignalsEnabled (configProps )) {
343291 return AwsMetricAttributesSpanExporterBuilder .create (
344292 spanExporter , ResourceHolder .getResource ())
0 commit comments