forked from getsentry/sentry-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
89 lines (62 loc) · 1.72 KB
/
api.py
File metadata and controls
89 lines (62 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import inspect
from contextlib import contextmanager
from sentry_sdk.hub import Hub, init
from sentry_sdk.scope import Scope
from sentry_sdk.transport import Transport, HttpTransport
from sentry_sdk.client import Client
__all__ = ["Hub", "Scope", "Client", "Transport", "HttpTransport", "init"]
_initial_client = None
def public(f):
__all__.append(f.__name__)
return f
def hubmethod(f):
f.__doc__ = "%s\n\n%s" % (
"Alias for `Hub.%s`" % f.__name__,
inspect.getdoc(getattr(Hub, f.__name__)),
)
return public(f)
@hubmethod
def capture_event(event, hint=None):
hub = Hub.current
if hub is not None:
return hub.capture_event(event, hint)
@hubmethod
def capture_message(message, level=None):
hub = Hub.current
if hub is not None:
return hub.capture_message(message, level)
@hubmethod
def capture_exception(error=None):
hub = Hub.current
if hub is not None:
return hub.capture_exception(error)
@hubmethod
def add_breadcrumb(*args, **kwargs):
hub = Hub.current
if hub is not None:
return hub.add_breadcrumb(*args, **kwargs)
@hubmethod
def configure_scope(callback=None):
hub = Hub.current
if hub is not None:
return hub.configure_scope(callback)
elif callback is None:
@contextmanager
def inner():
yield Scope()
return inner()
@hubmethod
def push_scope(callback=None):
hub = Hub.current
if hub is not None:
return hub.push_scope(callback)
elif callback is None:
@contextmanager
def inner():
yield Scope()
return inner()
@hubmethod
def last_event_id():
hub = Hub.current
if hub is not None:
return hub.last_event_id()