Skip to content

Commit c6d8143

Browse files
authored
Move Sigv4 Log Configuration Message (#420)
*Description of changes:* Fixed log configuration warnings to properly indicate when required headers are missing or exporter protocol is incorrectly configured instead of keeping them clumped together when either one fails. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 7e430b6 commit c6d8143

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def _customize_span_exporter(span_exporter: SpanExporter, resource: Resource) ->
406406
return _create_aws_otlp_exporter(endpoint=endpoint, service=XRAY_SERVICE, region=region)
407407

408408
_logger.warning(
409-
"Improper configuration see: please export/set "
409+
"Improper configuration: please export/set "
410410
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf and OTEL_TRACES_EXPORTER=otlp"
411411
)
412412

@@ -438,15 +438,22 @@ def _customize_logs_exporter(log_exporter: LogExporter) -> LogExporter:
438438

439439
_logger.info("Detected using AWS OTLP Logs Endpoint.")
440440

441-
if isinstance(log_exporter, OTLPLogExporter) and _validate_and_fetch_logs_header().is_valid:
442-
endpoint, region = _extract_endpoint_and_region_from_otlp_endpoint(logs_endpoint)
443-
# Setting default compression mode to Gzip as this is the behavior in upstream's
444-
# collector otlp http exporter:
445-
# https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter
446-
return _create_aws_otlp_exporter(endpoint=endpoint, service=LOGS_SERIVCE, region=region)
441+
if isinstance(log_exporter, OTLPLogExporter):
442+
443+
if _validate_and_fetch_logs_header().is_valid:
444+
endpoint, region = _extract_endpoint_and_region_from_otlp_endpoint(logs_endpoint)
445+
# Setting default compression mode to Gzip as this is the behavior in upstream's
446+
# collector otlp http exporter:
447+
# https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter
448+
return _create_aws_otlp_exporter(endpoint=endpoint, service=LOGS_SERIVCE, region=region)
449+
450+
_logger.warning(
451+
"Improper configuration: Please configure the environment variable OTEL_EXPORTER_OTLP_LOGS_HEADERS "
452+
"to have values for x-aws-log-group and x-aws-log-stream"
453+
)
447454

448455
_logger.warning(
449-
"Improper configuration see: please export/set "
456+
"Improper configuration: please export/set "
450457
"OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf and OTEL_LOGS_EXPORTER=otlp"
451458
)
452459

@@ -651,12 +658,6 @@ def _validate_and_fetch_logs_header() -> OtlpLogHeaderSetting:
651658

652659
is_valid = log_group is not None and log_stream is not None
653660

654-
if not is_valid:
655-
_logger.warning(
656-
"Improper configuration: Please configure the environment variable OTEL_EXPORTER_OTLP_LOGS_HEADERS "
657-
"to have values for x-aws-log-group and x-aws-log-stream"
658-
)
659-
660661
return OtlpLogHeaderSetting(log_group, log_stream, namespace, is_valid)
661662

662663

0 commit comments

Comments
 (0)