Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1518381: enabling oob telemetry for local testing #1878

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/snowflake/snowpark/mock/_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self) -> None:
os.getenv("SNOWPARK_LOCAL_TESTING_INTERNAL_TELEMETRY", False)
)
self._deployment_url = self.PROD
self._enable = True

def _upload_payload(self, payload) -> None:
if not REQUESTS_AVAILABLE:
Expand Down Expand Up @@ -142,6 +143,19 @@ def add(self, event) -> None:
return
self._upload_payload(payload)

@property
def enabled(self) -> bool:
"""Whether the Telemetry service is enabled or not."""
return self._enabled

def enable(self) -> None:
"""Enable Telemetry Service."""
self._enabled = True

def disable(self) -> None:
"""Disable Telemetry Service."""
self._enabled = False

def export_queue_to_string(self):
logs = list()
while not self.queue.empty():
Expand Down
11 changes: 10 additions & 1 deletion tests/mock/test_oob_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,16 @@ def test_unit_connection(caplog, local_testing_telemetry_setup):

def test_unit_connection_disable_telemetry(caplog, local_testing_telemetry_setup):
# clean up queue first
LocalTestOOBTelemetryService.get_instance().export_queue_to_string()
telemetry_service = LocalTestOOBTelemetryService.get_instance()
assert telemetry_service.enabled is True
telemetry_service.export_queue_to_string()

telemetry_service.disable()
assert not telemetry_service.enabled

telemetry_service.enable()
assert telemetry_service.enabled is True

disabled_telemetry_conn = MockServerConnection(
options={"disable_local_testing_telemetry": True}
)
Expand Down
Loading