diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py index d37c585dbf6..9303a9e35f8 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py @@ -391,7 +391,7 @@ def get_aggregated_resources( try: detected_resource = future.result(timeout=timeout) # pylint: disable=broad-except - except concurrent.futures._base.TimeoutError: + except concurrent.futures.TimeoutError: if detector.raise_on_error: raise ex logger.warning( diff --git a/opentelemetry-sdk/tests/resources/test_resources.py b/opentelemetry-sdk/tests/resources/test_resources.py index 7bd3694f0dd..ca154276a2b 100644 --- a/opentelemetry-sdk/tests/resources/test_resources.py +++ b/opentelemetry-sdk/tests/resources/test_resources.py @@ -11,11 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import concurrent.futures import os import sys import unittest import uuid +from concurrent.futures import TimeoutError from logging import ERROR, WARNING from os import environ from unittest.mock import Mock, patch @@ -415,8 +415,7 @@ def test_resource_detector_ignore_error(self): def test_resource_detector_raise_error(self): resource_detector = Mock(spec=ResourceDetector) - ex = Exception() - resource_detector.detect.side_effect = ex + resource_detector.detect.side_effect = Exception() resource_detector.raise_on_error = True self.assertRaises( Exception, get_aggregated_resources, [resource_detector] @@ -425,7 +424,7 @@ def test_resource_detector_raise_error(self): @patch("opentelemetry.sdk.resources.logger") def test_resource_detector_timeout(self, mock_logger): resource_detector = Mock(spec=ResourceDetector) - resource_detector.detect.side_effect = concurrent.futures._base.TimeoutError() + resource_detector.detect.side_effect = TimeoutError() resource_detector.raise_on_error = False self.assertEqual( get_aggregated_resources([resource_detector]),