Skip to content

Commit 80bcf3e

Browse files
Remove sentry use from lib (#438)
* Remove sentry use from lib * remove try block
1 parent 03d6dbb commit 80bcf3e

4 files changed

Lines changed: 27 additions & 157 deletions

File tree

poetry.lock

Lines changed: 23 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dependencies = [
2626
"python-dotenv",
2727
"scikit-learn",
2828
"seaborn",
29-
"sentry-sdk (>=1.24.0,<2.0.0)",
3029
"tabulate (>=0.9.0,<0.10.0)",
3130
"tiktoken",
3231
"tqdm",

validmind/api_client.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from .client_config import client_config
2424
from .errors import MissingAPICredentialsError, MissingModelIdError, raise_api_error
25-
from .logging import get_logger, init_sentry, log_api_operation, send_single_error
25+
from .logging import get_logger, log_api_operation
2626
from .utils import NumpyEncoder, is_html, md_to_html, run_async
2727
from .vm_models.figure import Figure
2828

@@ -166,7 +166,7 @@ def _ping() -> Dict[str, Any]:
166166

167167
client_info = r.json()
168168

169-
init_sentry(client_info.get("sentry_config", {}))
169+
# Sentry removed: no telemetry initialization
170170

171171
# Only show this confirmation the first time we connect to the API
172172
ack_connected = not client_config.model
@@ -244,14 +244,7 @@ def init(
244244

245245
def reload():
246246
"""Reconnect to the ValidMind API and reload the project configuration."""
247-
248-
try:
249-
_ping()
250-
except Exception as e:
251-
# if the api host is https, assume we're not in dev mode and send to sentry
252-
if _api_host.startswith("https://"):
253-
send_single_error(e)
254-
raise e
247+
_ping()
255248

256249

257250
async def aget_metadata(content_id: str) -> Dict[str, Any]:

validmind/logging.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
import logging
88
import os
99
import time
10-
from typing import Any, Awaitable, Callable, Dict, Optional, TypeVar
11-
12-
import sentry_sdk
13-
from sentry_sdk.utils import event_from_exception, exc_info_from_error
14-
15-
from .__version__ import __version__
16-
17-
__dsn = "https://48f446843657444aa1e2c0d716ef864b@o1241367.ingest.sentry.io/4505239625465856"
10+
from typing import Any, Awaitable, Callable, Optional, TypeVar
1811

1912

2013
def _get_log_level() -> int:
@@ -55,45 +48,6 @@ def get_logger(
5548
return logger
5649

5750

58-
def init_sentry(server_config: Dict[str, Any]) -> None:
59-
"""Initialize Sentry SDK for sending logs back to ValidMind.
60-
61-
This will usually only be called by the API client module to initialize the
62-
Sentry connection after the user calls `validmind.init()`. This is because the DSN
63-
and other config options will be returned by the API.
64-
65-
Args:
66-
server_config (Dict[str, Any]): The config dictionary returned by the API.
67-
- send_logs (bool): Whether to send logs to Sentry (gets removed).
68-
- dsn (str): The Sentry DSN.
69-
...: Other config options for Sentry.
70-
71-
Returns:
72-
None.
73-
"""
74-
if os.getenv("VM_NO_TELEMETRY", False):
75-
return
76-
77-
if not server_config.get("send_logs", False):
78-
return
79-
80-
config = {
81-
"dsn": __dsn,
82-
"traces_sample_rate": 1.0,
83-
"release": f"validmind-python@{__version__}",
84-
"in_app_include": ["validmind"],
85-
"environment": "production",
86-
}
87-
config.update({k: v for k, v in server_config.items() if k != "send_logs"})
88-
89-
try:
90-
sentry_sdk.init(**config)
91-
except Exception as e:
92-
logger = get_logger(__name__)
93-
logger.info("Sentry failed to initialize - ignoring...")
94-
logger.debug(f"Sentry error: {str(e)}")
95-
96-
9751
F = TypeVar("F", bound=Callable[..., Any])
9852
AF = TypeVar("AF", bound=Callable[..., Awaitable[Any]])
9953

@@ -216,16 +170,3 @@ async def wrapped(*args: Any, **kwargs: Any) -> Any:
216170
return wrapped
217171

218172
return decorator
219-
220-
221-
def send_single_error(error: Exception) -> None:
222-
"""Send a single error to Sentry.
223-
224-
Args:
225-
error (Exception): The exception to send.
226-
"""
227-
event, hint = event_from_exception(exc_info_from_error(error))
228-
client = sentry_sdk.Client(__dsn, release=f"validmind-python@{__version__}")
229-
client.capture_event(event, hint=hint)
230-
231-
time.sleep(0.25) # wait for the event to be sent

0 commit comments

Comments
 (0)