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 1313
1414 from sentry_sdk .utils import Event
1515
16+
1617_installed_modules = None
1718
1819
Original file line number Diff line number Diff line change 11from sentry_sdk .hub import Hub
22from sentry_sdk .integrations import Integration
3+ from sentry_sdk .scope import add_global_event_processor
34
5+ import sys
6+ import platform
47
58try :
69 from httplib import HTTPConnection # type: ignore
710except ImportError :
811 from http .client import HTTPConnection
912
13+ _RUNTIME_CONTEXT = {
14+ "name" : platform .python_implementation (),
15+ "version" : "%s.%s.%s" % (sys .version_info [:3 ]),
16+ "build" : sys .version ,
17+ }
18+
1019
1120class StdlibIntegration (Integration ):
1221 identifier = "stdlib"
@@ -16,6 +25,15 @@ def setup_once():
1625 # type: () -> None
1726 install_httplib ()
1827
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+
1937
2038def install_httplib ():
2139 # type: () -> None
You can’t perform that action at this time.
0 commit comments