Skip to content

Commit

Permalink
SNOW-1239792: disable oob telemetry in stored procedure (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aling authored Mar 18, 2024
1 parent 8a6b98a commit 7a8121d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/mock/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion src/snowflake/snowpark/mock/_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/mock/test_oob_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7a8121d

Please sign in to comment.