diff --git a/pinecone/config.py b/pinecone/config.py index e3f48228..876b34d1 100644 --- a/pinecone/config.py +++ b/pinecone/config.py @@ -7,14 +7,12 @@ import certifi import requests -import sentry_sdk import configparser from pinecone.core.client.exceptions import ApiKeyError from pinecone.core.api_action import ActionAPI, WhoAmIResponse from pinecone.core.utils import warn_deprecated from pinecone.core.utils.constants import CLIENT_VERSION, PARENT_LOGGER_NAME, DEFAULT_PARENT_LOGGER_LEVEL -from pinecone.core.utils.sentry import sentry_decorator as sentry from pinecone.core.client.configuration import Configuration as OpenApiConfiguration __all__ = [ @@ -26,14 +24,6 @@ _parent_logger.setLevel(DEFAULT_PARENT_LOGGER_LEVEL) -def _set_sentry_tags(config: dict): - sentry_sdk.set_tag("package_version", CLIENT_VERSION) - sentry_tag_names = ('environment', 'project_name', 'controller_host', 'username', 'user_label') - for key, val in config.items(): - if key in sentry_tag_names: - sentry_sdk.set_tag(key, val) - - class ConfigBase(NamedTuple): environment: str = "" api_key: str = "" @@ -122,8 +112,6 @@ def reset(self, config_file=None, **kwargs): config = config._replace(openapi_config=openapi_config) self._config = config - # Sentry - _set_sentry_tags({**whoami_response._asdict(), **self._config._asdict()}) def _preprocess_and_validate_config(self, config: dict) -> dict: """Normalize, filter, and validate config keys/values. @@ -189,7 +177,6 @@ def LOG_LEVEL(self): return logging.getLevelName(logging.getLogger('pinecone').level) -@sentry def init(api_key: str = None, host: str = None, environment: str = None, project_name: str = None, log_level: str = None, openapi_config: OpenApiConfiguration = None, config: str = "~/.pinecone", **kwargs): diff --git a/pinecone/core/grpc/index_grpc.py b/pinecone/core/grpc/index_grpc.py index 8c37de20..691589f6 100644 --- a/pinecone/core/grpc/index_grpc.py +++ b/pinecone/core/grpc/index_grpc.py @@ -22,7 +22,6 @@ from pinecone.core.grpc.retry import RetryOnRpcErrorClientInterceptor, RetryConfig from pinecone.core.utils import _generate_request_id, dict_to_proto_struct, fix_tuple_length from pinecone.core.utils.constants import MAX_MSG_SIZE, REQUEST_ID, CLIENT_VERSION -from pinecone.core.utils.sentry import sentry_decorator as sentry from pinecone.exceptions import PineconeException __all__ = ["GRPCIndex", "GRPCVector", "GRPCQueryVector"] @@ -127,7 +126,6 @@ def grpc_server_on(self) -> bool: except grpc.FutureTimeoutError: return False - @sentry def close(self): """Closes the connection to the index.""" try: @@ -137,7 +135,6 @@ def close(self): def _wrap_grpc_call(self, func, request, timeout=None, metadata=None, credentials=None, wait_for_ready=None, compression=None): - @sentry @wraps(func) def wrapped(): user_provided_metadata = metadata or {} @@ -244,7 +241,6 @@ class GRPCIndex(GRPCIndexBase): def stub_class(self): return VectorServiceStub - @sentry def upsert(self, vectors, async_req=False, **kwargs): def _vector_transform(item): if isinstance(item, GRPCVector): @@ -262,7 +258,6 @@ def _vector_transform(item): else: return self._wrap_grpc_call(self.stub.Upsert, request, timeout=timeout) - @sentry def delete(self, *args, async_req=False, **kwargs): request = DeleteRequest(*args, **kwargs) timeout = kwargs.pop('timeout', None) @@ -272,7 +267,6 @@ def delete(self, *args, async_req=False, **kwargs): else: return self._wrap_grpc_call(self.stub.Delete, request, timeout=timeout) - @sentry def fetch(self, *args, **kwargs): timeout = kwargs.pop('timeout', None) request = FetchRequest(*args, **kwargs) @@ -280,7 +274,6 @@ def fetch(self, *args, **kwargs): json_response = json_format.MessageToDict(response) return parse_fetch_response(json_response) - @sentry def query(self, queries, **kwargs): timeout = kwargs.pop('timeout', None) @@ -304,7 +297,6 @@ def _query_transform(item): json_response = json_format.MessageToDict(response) return parse_query_response(json_response) - @sentry def describe_index_stats(self, **kwargs): timeout = kwargs.pop('timeout', None) request = DescribeIndexStatsRequest() diff --git a/pinecone/core/utils/constants.py b/pinecone/core/utils/constants.py index 329fa1b4..e7ed81b5 100644 --- a/pinecone/core/utils/constants.py +++ b/pinecone/core/utils/constants.py @@ -31,6 +31,5 @@ class NodeType(str, enum.Enum): PACKAGE_ENVIRONMENT = get_environment() or "development" -SENTRY_DSN_TXT_RECORD = "pinecone-client.sentry.pinecone.io" CLIENT_VERSION = get_version() CLIENT_ID = f'python-client-{CLIENT_VERSION}' diff --git a/pinecone/core/utils/sentry.py b/pinecone/core/utils/sentry.py deleted file mode 100644 index dc37bf1d..00000000 --- a/pinecone/core/utils/sentry.py +++ /dev/null @@ -1,54 +0,0 @@ -# -# Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved. -# -import logging - -import dns.resolver -import sentry_sdk -import os -import json -import inspect -from functools import wraps - -from pinecone.core.utils.constants import PACKAGE_ENVIRONMENT, SENTRY_DSN_TXT_RECORD - - -_logger = logging.getLogger(__name__) - - -def sentry_decorator(func): - @wraps(func) - def inner_func(*args, **kwargs): - try: - return func(*args, **kwargs) - except Exception as e: - init_sentry() - sentry_sdk.capture_exception(e) - raise - - # Override signature - sig = inspect.signature(func) - inner_func.__signature__ = sig - return inner_func - - -def init_sentry(): - """Init Sentry if necessary. - - The Sentry DSN is stored as a txt record. - """ - if not sentry_sdk.Hub.current.client: - _logger.info("Sentry is not initialized.") - # sentry is not initialized - sentry_dsn = None - try: - dns_result = dns.resolver.resolve(SENTRY_DSN_TXT_RECORD, "TXT") - for res in dns_result: - sentry_dsn = json.loads(res.to_text()) - break - except Exception: - _logger.warning("Unable to resolve Sentry DSN.") - if sentry_dsn: - debug = os.getenv("SENTRY_DEBUG") == "True" - sentry_sdk.init(dsn=sentry_dsn, debug=debug, environment=PACKAGE_ENVIRONMENT, traces_sample_rate=0.1) - return None diff --git a/pinecone/index.py b/pinecone/index.py index d4827f4f..e5614061 100644 --- a/pinecone/index.py +++ b/pinecone/index.py @@ -6,7 +6,6 @@ from pinecone import Config from pinecone.core.client import ApiClient, Configuration -from pinecone.core.utils.sentry import sentry_decorator as sentry from .core.client.models import FetchResponse, ProtobufAny, QueryRequest, QueryResponse, QueryVector, RpcStatus, \ ScoredVector, SingleQueryResults, DescribeIndexStatsResponse, UpsertRequest, UpsertResponse, Vector from pinecone.core.client.api.vector_operations_api import VectorOperationsApi @@ -45,7 +44,6 @@ def __init__(self, index_name: str, pool_threads=1): self.user_agent = get_user_agent() self._vector_api = VectorOperationsApi(self) - @sentry @validate_and_convert_errors def upsert(self, vectors, **kwargs): _check_type = kwargs.pop('_check_type', False) @@ -67,17 +65,14 @@ def _vector_transform(item): **{k: v for k, v in kwargs.items() if k in _OPENAPI_ENDPOINT_PARAMS} ) - @sentry @validate_and_convert_errors def delete(self, *args, **kwargs): return self._vector_api.delete(*args, **kwargs) - @sentry @validate_and_convert_errors def fetch(self, *args, **kwargs): return self._vector_api.fetch(*args, **kwargs) - @sentry @validate_and_convert_errors def query(self, queries, **kwargs): _check_type = kwargs.pop('_check_type', False) @@ -101,7 +96,6 @@ def _query_transform(item): **{k: v for k, v in kwargs.items() if k in _OPENAPI_ENDPOINT_PARAMS} ) - @sentry @validate_and_convert_errors def describe_index_stats(self, *args, **kwargs): return self._vector_api.describe_index_stats(*args, **kwargs) diff --git a/pinecone/info.py b/pinecone/info.py index fa8764a0..be84dcf7 100644 --- a/pinecone/info.py +++ b/pinecone/info.py @@ -2,7 +2,6 @@ # Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved. # -from pinecone.core.utils.sentry import sentry_decorator as sentry from pinecone.core.api_action import ActionAPI, VersionResponse, WhoAmIResponse from pinecone.config import Config @@ -16,21 +15,18 @@ def _get_action_api(): return ActionAPI(host=Config.CONTROLLER_HOST, api_key=Config.API_KEY) -@sentry def version() -> VersionResponse: """Returns version information (client and server).""" api = _get_action_api() return api.version() -@sentry def whoami() -> WhoAmIResponse: """Returns the details of the currently authenticated API key.""" api = _get_action_api() return api.whoami() -@sentry def wait_controller_ready(timeout: int = 30): connection = False max_time = time.time() + timeout diff --git a/pinecone/manage.py b/pinecone/manage.py index 34b57d1f..26901bce 100644 --- a/pinecone/manage.py +++ b/pinecone/manage.py @@ -12,7 +12,6 @@ from pinecone.core.client.configuration import Configuration from pinecone.core.client.model.create_request import CreateRequest from pinecone.core.client.model.patch_request import PatchRequest -from pinecone.core.utils.sentry import sentry_decorator as sentry from pinecone.core.utils import get_user_agent __all__ = [ @@ -55,7 +54,6 @@ def _get_status(name: str): return response['status'] -@sentry def create_index( name: str, dimension: int, @@ -132,7 +130,6 @@ def is_ready(): 'https://www.pinecone.io/docs/api/operation/describe_index/'))) -@sentry def delete_index(name: str, timeout: int = None): """Deletes a Pinecone index. @@ -163,7 +160,6 @@ def get_remaining(): 'https://www.pinecone.io/docs/api/operation/list_indexes/'))) -@sentry def list_indexes(): """Lists all indexes.""" api_instance = _get_api_instance() @@ -171,7 +167,6 @@ def list_indexes(): return response -@sentry def describe_index(name: str): """Describes a Pinecone index. @@ -188,7 +183,6 @@ def describe_index(name: str): index_config=db['index_config'], status={'ready': ready}) -@sentry def scale_index(name: str, replicas: int): """Increases number of replicas for the index. diff --git a/requirements.txt b/requirements.txt index dd553879..05b55a2a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ requests>=2.19.0 pyyaml>=5.4 loguru>=0.5.0 typing-extensions>=3.7.4 -sentry-sdk>=1.0.0 dnspython>=2.0.0 # openapi generated client: python_dateutil >= 2.5.3