diff --git a/src/snowflake/snowpark/mock/_connection.py b/src/snowflake/snowpark/mock/_connection.py index 1af3e8872b9..1a7bbef1ee1 100644 --- a/src/snowflake/snowpark/mock/_connection.py +++ b/src/snowflake/snowpark/mock/_connection.py @@ -242,7 +242,7 @@ def __init__(self, options: Optional[Dict[str, Any]] = None) -> None: "disable_local_testing_telemetry", False ) self._oob_telemetry = LocalTestOOBTelemetryService.get_instance() - if self._disable_local_testing_telemetry: + if self._disable_local_testing_telemetry or is_in_stored_procedure(): # after disabling, the log will basically be a no-op, not sending any telemetry self._oob_telemetry.disable() else: diff --git a/src/snowflake/snowpark/mock/_telemetry.py b/src/snowflake/snowpark/mock/_telemetry.py index a7a632c44eb..0dd7eb35ed9 100644 --- a/src/snowflake/snowpark/mock/_telemetry.py +++ b/src/snowflake/snowpark/mock/_telemetry.py @@ -13,7 +13,6 @@ from snowflake.connector.compat import OK from snowflake.connector.secret_detector import SecretDetector from snowflake.connector.telemetry_oob import REQUEST_TIMEOUT, TelemetryService -from snowflake.connector.vendored import requests from snowflake.snowpark._internal.utils import ( get_os_name, get_python_version, @@ -84,6 +83,10 @@ def _upload_payload(self, payload) -> None: success = True response = None try: + # import here is because stored proc doesn't have vendored request module + # have it at the top will cause import error in stored procedure running + from snowflake.connector.vendored import requests + with requests.Session() as session: response = session.post( self._deployment_url, diff --git a/tests/mock/test_oob_telemetry.py b/tests/mock/test_oob_telemetry.py index 906e79cbcc3..c3060e370da 100644 --- a/tests/mock/test_oob_telemetry.py +++ b/tests/mock/test_oob_telemetry.py @@ -17,6 +17,11 @@ from snowflake.snowpark.mock._connection import MockServerConnection from snowflake.snowpark.mock._telemetry import LocalTestOOBTelemetryService from snowflake.snowpark.session import Session +from tests.utils import IS_IN_STORED_PROC + +pytestmark = pytest.mark.skipif( + IS_IN_STORED_PROC, reason="OOB Telemetry not available in stored procedure" +) def test_unit_oob_connection_telemetry(caplog, local_testing_telemetry_setup):