Skip to content

Commit 9a47ab3

Browse files
committed
lint fix + test fix
1 parent 6cb0f55 commit 9a47ab3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_instrumentation_patch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import os
55
from logging import Logger, getLogger
66

7-
import pkg_resources # pylint: disable=unused-import
7+
# pylint: disable=unused-import
8+
import pkg_resources
89

910
from amazon.opentelemetry.distro._utils import is_installed
1011
from amazon.opentelemetry.distro.patches._resource_detector_patches import _apply_resource_detector_patches

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ def test_sigv4_exporter_init_invalid_cw_otlp_endpoint(self):
101101

102102
@patch("requests.Session.post")
103103
@patch("botocore.auth.SigV4Auth.add_auth")
104-
def test_sigv4_exporter_export_does_not_add_sigv4_if_not_valid_cw_endpoint(self, mock_sigv4_auth, requests_mock):
104+
@patch("botocore.session.Session")
105+
def test_sigv4_exporter_export_does_not_add_sigv4_if_not_valid_cw_endpoint(
106+
self, botocore_mock, mock_sigv4_auth, requests_mock
107+
):
105108
"""Tests that if the OTLP endpoint is not a valid XRay endpoint but the credentials are valid,
106109
SigV4 authentication method is called but fails so NO headers are injected into the existing Session headers."""
107110

@@ -119,6 +122,13 @@ def test_sigv4_exporter_export_does_not_add_sigv4_if_not_valid_cw_endpoint(self,
119122
# SigV4 mock authentication injection
120123
mock_sigv4_auth.side_effect = self.mock_add_auth
121124

125+
mock_botocore_session = MagicMock()
126+
botocore_mock.return_value = mock_botocore_session
127+
128+
mock_botocore_session.get_credentials.return_value = Credentials(
129+
access_key="test_key", secret_key="test_secret", token="test_token"
130+
)
131+
122132
# For each invalid CW OTLP endpoint, validate that SigV4 is not injected
123133
self.invalid_otlp_tracing_endpoints.append("https://xray.bad-region-1.amazonaws.com/v1/traces")
124134
for bad_endpoint in self.invalid_otlp_tracing_endpoints:

0 commit comments

Comments
 (0)