Skip to content

Commit d8010e4

Browse files
committed
cleanup
1 parent aa16517 commit d8010e4

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_configurator.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"
9191
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
9292

93-
AWS_TRACES_OTLP_ENDPOINT_PATTERN = r"^https://xray\\.([a-z0-9-]+)\\.amazonaws\\.com/v1/traces$"
94-
AWS_LOGS_OTLP_ENDPOINT_PATTERN = r"^https://logs\\.([a-z0-9-]+)\\.amazonaws\\.com/v1/logs$"
93+
AWS_TRACES_OTLP_ENDPOINT_PATTERN = r"https://xray\.([a-z0-9-]+)\.amazonaws\.com/v1/traces$"
94+
AWS_LOGS_OTLP_ENDPOINT_PATTERN = r"https://logs\.([a-z0-9-]+)\.amazonaws\.com/v1/logs$"
9595

9696
# UDP package size is not larger than 64KB
9797
LAMBDA_SPAN_EXPORT_BATCH_SIZE = 10
@@ -177,7 +177,7 @@ def _init_logging(
177177
set_logger_provider(provider)
178178

179179
for _, exporter_class in exporters.items():
180-
exporter_args = {}
180+
exporter_args: Dict[str, any] = {}
181181
log_exporter = _customize_logs_exporter(exporter_class(**exporter_args), resource)
182182
provider.add_log_record_processor(BatchLogRecordProcessor(exporter=log_exporter))
183183

@@ -496,16 +496,12 @@ def _is_lambda_environment():
496496
def is_aws_otlp_endpoint(otlp_endpoint: str = None, service: str = "xray") -> bool:
497497
"""Is the given endpoint an AWS OTLP endpoint?"""
498498

499+
pattern = AWS_TRACES_OTLP_ENDPOINT_PATTERN if service == "xray" else AWS_LOGS_OTLP_ENDPOINT_PATTERN
500+
499501
if not otlp_endpoint:
500502
return False
501503

502-
if service == "xray":
503-
return bool(re.match(AWS_TRACES_OTLP_ENDPOINT_PATTERN, otlp_endpoint.lower()))
504-
505-
if service == "logs":
506-
return bool(re.match(AWS_LOGS_OTLP_ENDPOINT_PATTERN, otlp_endpoint.lower()))
507-
508-
return False
504+
return bool(re.match(pattern, otlp_endpoint.lower()))
509505

510506

511507
def _get_metric_export_interval():

0 commit comments

Comments
 (0)