File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 13
13
14
14
from sentry_sdk .utils import Event
15
15
16
+
16
17
_installed_modules = None
17
18
18
19
Original file line number Diff line number Diff line change 1
1
from sentry_sdk .hub import Hub
2
2
from sentry_sdk .integrations import Integration
3
+ from sentry_sdk .scope import add_global_event_processor
3
4
5
+ import sys
6
+ import platform
4
7
5
8
try :
6
9
from httplib import HTTPConnection # type: ignore
7
10
except ImportError :
8
11
from http .client import HTTPConnection
9
12
13
+ _RUNTIME_CONTEXT = {
14
+ "name" : platform .python_implementation (),
15
+ "version" : "%s.%s.%s" % (sys .version_info [:3 ]),
16
+ "build" : sys .version ,
17
+ }
18
+
10
19
11
20
class StdlibIntegration (Integration ):
12
21
identifier = "stdlib"
@@ -16,6 +25,15 @@ def setup_once():
16
25
# type: () -> None
17
26
install_httplib ()
18
27
28
+ @add_global_event_processor
29
+ def add_python_runtime_context (event , hint ):
30
+ if Hub .current .get_integration (StdlibIntegration ) is not None :
31
+ contexts = event .setdefault ("contexts" , {})
32
+ if isinstance (contexts , dict ) and "runtime" not in contexts :
33
+ contexts ["runtime" ] = _RUNTIME_CONTEXT
34
+
35
+ return event
36
+
19
37
20
38
def install_httplib ():
21
39
# type: () -> None
You can’t perform that action at this time.
0 commit comments