|
7 | 7 | import logging |
8 | 8 | import os |
9 | 9 | 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 |
18 | 11 |
|
19 | 12 |
|
20 | 13 | def _get_log_level() -> int: |
@@ -55,45 +48,6 @@ def get_logger( |
55 | 48 | return logger |
56 | 49 |
|
57 | 50 |
|
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 | | - |
97 | 51 | F = TypeVar("F", bound=Callable[..., Any]) |
98 | 52 | AF = TypeVar("AF", bound=Callable[..., Awaitable[Any]]) |
99 | 53 |
|
@@ -216,16 +170,3 @@ async def wrapped(*args: Any, **kwargs: Any) -> Any: |
216 | 170 | return wrapped |
217 | 171 |
|
218 | 172 | 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