Skip to content

Commit c3c2aae

Browse files
committed
Fix lint and unit tests
1 parent 056618b commit c3c2aae

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ def _create_emf_exporter():
805805
if _is_lambda_environment() and not log_header_setting.is_valid():
806806
# pylint: disable=import-outside-toplevel
807807
from amazon.opentelemetry.distro.exporter.aws.metrics.console_emf_exporter import ConsoleEmfExporter
808+
808809
return ConsoleEmfExporter(namespace=log_header_setting.namespace)
809810

810811
# For non-Lambda environment or Lambda with valid headers - use CloudWatch EMF exporter

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/exporter/aws/metrics/test_aws_cloudwatch_emf_exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,19 @@ def test_shutdown(self, mock_force_flush):
635635
mock_force_flush.assert_called_once_with(5000)
636636

637637
# pylint: disable=broad-exception-caught
638-
def test_send_log_event_method_exists(self):
639-
"""Test that _send_log_event method exists and can be called."""
638+
def test_export_method_exists(self):
639+
"""Test that _export method exists and can be called."""
640640
# Just test that the method exists and doesn't crash with basic input
641641
log_event = {"message": "test message", "timestamp": 1234567890}
642642

643643
# Mock the log client to avoid actual AWS calls
644644
with patch.object(self.exporter.log_client, "send_log_event") as mock_send:
645645
# Should not raise an exception
646646
try:
647-
self.exporter._send_log_event(log_event)
647+
self.exporter._export(log_event)
648648
mock_send.assert_called_once_with(log_event)
649649
except Exception as error:
650-
self.fail(f"_send_log_event raised an exception: {error}")
650+
self.fail(f"_export raised an exception: {error}")
651651

652652

653653
if __name__ == "__main__":

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/exporter/aws/metrics/test_console_emf_exporter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ def test_send_log_event(self):
3535
'"Dimensions":[["Service"]],"Metrics":[{"Name":"TestMetric","Unit":"Count"}]}]},'
3636
'"Service":"test-service","TestMetric":42}'
3737
)
38-
log_event = {
39-
"message": test_message,
40-
"timestamp": 1640995200000
41-
}
38+
log_event = {"message": test_message, "timestamp": 1640995200000}
4239

4340
# Capture stdout to verify the output
44-
with patch('sys.stdout', new_callable=StringIO) as mock_stdout:
41+
with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
4542
exporter._export(log_event)
4643

4744
# Verify the message was printed to stdout

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_opentelementry_configurator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ def test_customize_span_exporter_sigv4(self):
508508
bad_configs.append(config)
509509

510510
for config in good_configs:
511+
_clear_logs_header_cache()
511512
self.customize_exporter_test(
512513
config,
513514
_customize_span_exporter,
@@ -519,6 +520,7 @@ def test_customize_span_exporter_sigv4(self):
519520
)
520521

521522
for config in bad_configs:
523+
_clear_logs_header_cache()
522524
self.customize_exporter_test(
523525
config,
524526
_customize_span_exporter,
@@ -616,6 +618,7 @@ def test_customize_logs_exporter_sigv4(self):
616618
bad_configs.append(config)
617619

618620
for config in good_configs:
621+
_clear_logs_header_cache()
619622
self.customize_exporter_test(
620623
config,
621624
_customize_logs_exporter,
@@ -626,6 +629,7 @@ def test_customize_logs_exporter_sigv4(self):
626629
)
627630

628631
for config in bad_configs:
632+
_clear_logs_header_cache()
629633
self.customize_exporter_test(
630634
config, _customize_logs_exporter, OTLPLogExporter(), OTLPLogExporter, Session, Compression.NoCompression
631635
)

0 commit comments

Comments
 (0)