Skip to content

Commit

Permalink
SNOW-1563453: remove oob telemetry usage in connector (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aling authored Aug 7, 2024
1 parent 706bc2f commit 34abbaf
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 89 deletions.
8 changes: 0 additions & 8 deletions src/snowflake/connector/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
PARAMETER_CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY,
PARAMETER_CLIENT_STORE_TEMPORARY_CREDENTIAL,
PARAMETER_CLIENT_TELEMETRY_ENABLED,
PARAMETER_CLIENT_TELEMETRY_OOB_ENABLED,
PARAMETER_CLIENT_VALIDATE_DEFAULT_PARAMETERS,
PARAMETER_ENABLE_STAGE_S3_PRIVATELINK_FOR_US_EAST_1,
PARAMETER_QUERY_CONTEXT_CACHE_SIZE,
Expand Down Expand Up @@ -106,7 +105,6 @@
)
from .sqlstate import SQLSTATE_CONNECTION_NOT_EXISTS, SQLSTATE_FEATURE_NOT_SUPPORTED
from .telemetry import TelemetryClient, TelemetryData, TelemetryField
from .telemetry_oob import TelemetryService
from .time_util import HeartBeatTimer, get_time_millis
from .url_util import extract_top_level_domain_from_hostname
from .util_text import construct_hostname, parse_account, split_statements
Expand Down Expand Up @@ -720,7 +718,6 @@ def connect(self, **kwargs) -> None:
logger.debug("connect")
if len(kwargs) > 0:
self.__config(**kwargs)
TelemetryService.get_instance().update_context(kwargs)

if self.enable_connection_diag:
exceptions_dict = {}
Expand Down Expand Up @@ -1718,11 +1715,6 @@ def _update_parameters(
self._session_parameters[name] = value
if PARAMETER_CLIENT_TELEMETRY_ENABLED == name:
self.telemetry_enabled = value
elif PARAMETER_CLIENT_TELEMETRY_OOB_ENABLED == name:
if value:
TelemetryService.get_instance().enable()
else:
TelemetryService.get_instance().disable()
elif PARAMETER_CLIENT_SESSION_KEEP_ALIVE == name:
# Only set if the local config is None.
# Always give preference to user config.
Expand Down
6 changes: 0 additions & 6 deletions src/snowflake/connector/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from .compat import BASE_EXCEPTION_CLASS
from .secret_detector import SecretDetector
from .telemetry import TelemetryData, TelemetryField
from .telemetry_oob import TelemetryService
from .time_util import get_time_millis

if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -167,11 +166,6 @@ def send_exception_telemetry(
)
except AttributeError:
logger.debug("Cursor failed to log to telemetry.", exc_info=True)
elif connection is None:
# Send with out-of-band telemetry

telemetry_oob = TelemetryService.get_instance()
telemetry_oob.log_general_exception(self.__class__.__name__, telemetry_data)

def exception_telemetry(
self,
Expand Down
64 changes: 0 additions & 64 deletions src/snowflake/connector/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import logging
import re
import time
import traceback
import uuid
from collections import OrderedDict
from threading import Lock
Expand Down Expand Up @@ -92,9 +91,7 @@
SQLSTATE_CONNECTION_NOT_EXISTS,
SQLSTATE_CONNECTION_REJECTED,
SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED,
SQLSTATE_IO_ERROR,
)
from .telemetry_oob import TelemetryService
from .time_util import (
DEFAULT_MASTER_VALIDITY_IN_SECONDS,
TimeoutBackoffCtx,
Expand Down Expand Up @@ -230,14 +227,6 @@ def raise_failed_request_error(
method: str,
response: Response,
) -> None:
TelemetryService.get_instance().log_http_request_error(
f"HttpError{response.status_code}",
url,
method,
SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED,
ER_FAILED_TO_REQUEST,
response=response,
)
Error.errorhandler_wrapper(
connection,
None,
Expand Down Expand Up @@ -902,32 +891,8 @@ def _request_exec_wrapper(
if return_object is not None:
return return_object
self._handle_unknown_error(method, full_url, headers, data, conn)
TelemetryService.get_instance().log_http_request_error(
"HttpRequestUnknownError",
full_url,
method,
SQLSTATE_IO_ERROR,
ER_FAILED_TO_REQUEST,
retry_timeout=retry_ctx.timeout,
retry_count=retry_ctx.current_retry_count,
)
return {}
except RetryRequest as e:
if (
retry_ctx.current_retry_count
== TelemetryService.get_instance().num_of_retry_to_trigger_telemetry
):
TelemetryService.get_instance().log_http_request_error(
"HttpRequestRetry%dTimes" % retry_ctx.current_retry_count,
full_url,
method,
SQLSTATE_IO_ERROR,
ER_FAILED_TO_REQUEST,
retry_timeout=retry_ctx.timeout,
retry_count=retry_ctx.current_retry_count,
exception=str(e),
stack_trace=traceback.format_exc(),
)
cause = e.args[0]
if no_retry:
self.log_and_handle_http_error_with_cause(
Expand Down Expand Up @@ -1001,17 +966,6 @@ def log_and_handle_http_error_with_cause(
) -> None:
cause = e.args[0]
logger.error(cause, exc_info=True)
TelemetryService.get_instance().log_http_request_error(
"HttpRequestRetryTimeout" if timed_out else f"HttpRequestError: {cause}",
full_url,
method,
SQLSTATE_IO_ERROR,
ER_FAILED_TO_REQUEST,
retry_timeout=retry_timeout,
retry_count=retry_count,
exception=str(e),
stack_trace=traceback.format_exc(),
)
if isinstance(cause, Error):
Error.errorhandler_wrapper_from_cause(conn, cause)
else:
Expand Down Expand Up @@ -1149,15 +1103,6 @@ def _request_exec(
raw_ret.close() # ensure response is closed
except SSLError as se:
logger.debug("Hit non-retryable SSL error, %s", str(se))
TelemetryService.get_instance().log_http_request_error(
"CertificateException%s" % str(se),
full_url,
method,
SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED,
ER_FAILED_TO_REQUEST,
exception=se,
stack_trace=traceback.format_exc(),
)

except (
BadStatusLine,
Expand Down Expand Up @@ -1190,15 +1135,6 @@ def _request_exec(
)
raise RetryRequest(err)
except Exception as err:
TelemetryService.get_instance().log_http_request_error(
"HttpException%s" % str(err),
full_url,
method,
SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED,
ER_FAILED_TO_REQUEST,
exception=err,
stack_trace=traceback.format_exc(),
)
raise err

def make_requests_session(self) -> Session:
Expand Down
11 changes: 0 additions & 11 deletions src/snowflake/connector/ocsp_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sys
import tempfile
import time
import traceback
from base64 import b64decode, b64encode
from datetime import datetime, timezone
from logging import getLogger
Expand Down Expand Up @@ -56,7 +55,6 @@
)
from snowflake.connector.errors import RevocationCheckError
from snowflake.connector.network import PYTHON_CONNECTOR_USER_AGENT
from snowflake.connector.telemetry_oob import TelemetryService

from . import constants
from .backoff_policies import exponential_backoff
Expand Down Expand Up @@ -250,15 +248,6 @@ def generate_telemetry_data(
is_oob_telemetry=True,
)

telemetry_client = TelemetryService.get_instance()
telemetry_client.log_ocsp_exception(
event_type,
telemetry_data,
exception=str(exception),
stack_trace=traceback.format_exc(),
urgent=urgent,
)

return telemetry_data
# To be updated once Python Driver has out of band telemetry.
# telemetry_client = TelemetryClient()
Expand Down

0 comments on commit 34abbaf

Please sign in to comment.