|
5 | 5 | import uuid
|
6 | 6 |
|
7 | 7 | from sentry_sdk.attachments import Attachment
|
8 |
| -from sentry_sdk._compat import datetime_utcnow |
9 |
| -from sentry_sdk.consts import FALSE_VALUES |
10 | 8 | from sentry_sdk._functools import wraps
|
11 |
| -from sentry_sdk.session import Session |
12 | 9 | from sentry_sdk.tracing_utils import (
|
13 | 10 | Baggage,
|
14 | 11 | extract_sentrytrace_data,
|
|
23 | 20 | from sentry_sdk._types import TYPE_CHECKING
|
24 | 21 | from sentry_sdk.utils import logger, capture_internal_exceptions
|
25 | 22 |
|
| 23 | +from sentry_sdk.consts import FALSE_VALUES |
| 24 | + |
| 25 | + |
26 | 26 | if TYPE_CHECKING:
|
27 | 27 | from typing import Any
|
28 | 28 | from typing import Dict
|
|
36 | 36 |
|
37 | 37 | from sentry_sdk._types import (
|
38 | 38 | Breadcrumb,
|
39 |
| - BreadcrumbHint, |
40 | 39 | Event,
|
41 | 40 | EventProcessor,
|
42 | 41 | ErrorProcessor,
|
|
47 | 46 |
|
48 | 47 | from sentry_sdk.profiler import Profile
|
49 | 48 | from sentry_sdk.tracing import Span
|
| 49 | + from sentry_sdk.session import Session |
50 | 50 |
|
51 | 51 | F = TypeVar("F", bound=Callable[..., Any])
|
52 | 52 | T = TypeVar("T")
|
@@ -517,97 +517,6 @@ def add_attachment(
|
517 | 517 | )
|
518 | 518 | )
|
519 | 519 |
|
520 |
| - def add_breadcrumb(self, crumb=None, hint=None, **kwargs): |
521 |
| - # type: (Optional[Breadcrumb], Optional[BreadcrumbHint], Any) -> None |
522 |
| - """ |
523 |
| - Adds a breadcrumb. |
524 |
| -
|
525 |
| - :param crumb: Dictionary with the data as the sentry v7/v8 protocol expects. |
526 |
| -
|
527 |
| - :param hint: An optional value that can be used by `before_breadcrumb` |
528 |
| - to customize the breadcrumbs that are emitted. |
529 |
| - """ |
530 |
| - client = kwargs.pop("client", None) |
531 |
| - if client is None: |
532 |
| - return |
533 |
| - |
534 |
| - before_breadcrumb = client.options.get("before_breadcrumb") |
535 |
| - max_breadcrumbs = client.options.get("max_breadcrumbs") |
536 |
| - |
537 |
| - crumb = dict(crumb or ()) # type: Breadcrumb |
538 |
| - crumb.update(kwargs) |
539 |
| - if not crumb: |
540 |
| - return |
541 |
| - |
542 |
| - hint = dict(hint or ()) # type: Hint |
543 |
| - |
544 |
| - if crumb.get("timestamp") is None: |
545 |
| - crumb["timestamp"] = datetime_utcnow() |
546 |
| - if crumb.get("type") is None: |
547 |
| - crumb["type"] = "default" |
548 |
| - |
549 |
| - if before_breadcrumb is not None: |
550 |
| - new_crumb = before_breadcrumb(crumb, hint) |
551 |
| - else: |
552 |
| - new_crumb = crumb |
553 |
| - |
554 |
| - if new_crumb is not None: |
555 |
| - self._breadcrumbs.append(new_crumb) |
556 |
| - else: |
557 |
| - logger.info("before breadcrumb dropped breadcrumb (%s)", crumb) |
558 |
| - |
559 |
| - while len(self._breadcrumbs) > max_breadcrumbs: |
560 |
| - self._breadcrumbs.popleft() |
561 |
| - |
562 |
| - def start_session(self, *args, **kwargs): |
563 |
| - # type: (*Any, **Any) -> None |
564 |
| - """Starts a new session.""" |
565 |
| - client = kwargs.pop("client", None) |
566 |
| - session_mode = kwargs.pop("session_mode", "application") |
567 |
| - |
568 |
| - self.end_session(client=client) |
569 |
| - |
570 |
| - self._session = Session( |
571 |
| - release=client.options["release"] if client else None, |
572 |
| - environment=client.options["environment"] if client else None, |
573 |
| - user=self._user, |
574 |
| - session_mode=session_mode, |
575 |
| - ) |
576 |
| - |
577 |
| - def end_session(self, *args, **kwargs): |
578 |
| - # type: (*Any, **Any) -> None |
579 |
| - """Ends the current session if there is one.""" |
580 |
| - client = kwargs.pop("client", None) |
581 |
| - |
582 |
| - session = self._session |
583 |
| - self._session = None |
584 |
| - |
585 |
| - if session is not None: |
586 |
| - session.close() |
587 |
| - if client is not None: |
588 |
| - client.capture_session(session) |
589 |
| - |
590 |
| - def stop_auto_session_tracking(self, *args, **kwargs): |
591 |
| - # type: (*Any, **Any) -> None |
592 |
| - """Stops automatic session tracking. |
593 |
| -
|
594 |
| - This temporarily session tracking for the current scope when called. |
595 |
| - To resume session tracking call `resume_auto_session_tracking`. |
596 |
| - """ |
597 |
| - client = kwargs.pop("client", None) |
598 |
| - |
599 |
| - self.end_session(client=client) |
600 |
| - |
601 |
| - self._force_auto_session_tracking = False |
602 |
| - |
603 |
| - def resume_auto_session_tracking(self): |
604 |
| - # type: (...) -> None |
605 |
| - """Resumes automatic session tracking for the current scope if |
606 |
| - disabled earlier. This requires that generally automatic session |
607 |
| - tracking is enabled. |
608 |
| - """ |
609 |
| - self._force_auto_session_tracking = None |
610 |
| - |
611 | 520 | def add_event_processor(
|
612 | 521 | self, func # type: EventProcessor
|
613 | 522 | ):
|
|
0 commit comments