whatap-python 1.7.8__tar.gz → 1.7.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of whatap-python might be problematic. Click here for more details.
- {whatap_python-1.7.8 → whatap_python-1.7.9}/PKG-INFO +1 -1
- whatap_python-1.7.9/whatap/build.py +4 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_django.py +10 -1
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_flask.py +12 -2
- whatap_python-1.7.9/whatap/trace/mod/application_tornado.py +161 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/trace_import.py +9 -5
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap_python.egg-info/PKG-INFO +1 -1
- whatap_python-1.7.8/whatap/build.py +0 -4
- whatap_python-1.7.8/whatap/trace/mod/application_tornado.py +0 -41
- {whatap_python-1.7.8 → whatap_python-1.7.9}/README.md +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/setup.cfg +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/setup.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/LICENSE +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/README.rst +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/__main__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/agent/darwin/amd64/whatap_python +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/agent/darwin/arm64/whatap_python +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/agent/linux/amd64/whatap_python +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/agent/linux/arm64/whatap_python +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/bootstrap/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/bootstrap/sitecustomize.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/conf/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/conf/configuration.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/conf/configure.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/conf/license.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/control/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/counter/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/counter/counter_manager.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/counter/tasks/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/counter/tasks/openfiledescriptor.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/io/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/io/data_inputx.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/io/data_outputx.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/async_sender.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/packet_enum.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/packet_type_enum.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/param_def.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/stackhelper.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/udp_session.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/net/udp_thread.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/pack/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/pack/logSinkPack.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/pack/pack.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/pack/pack_enum.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/pack/tagCountPack.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/scripts/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/amqp_kombu.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/amqp_pika.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_bottle.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_celery.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_cherrypy.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_django_asgi.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_django_py3.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_fastapi.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_frappe.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_graphql.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_nameko.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/application_wsgi.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/database_cxoracle.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/database_mongo.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/database_mysql.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/database_postgresql.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/database_redis.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/database_toolkit.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/email_smtp.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/httpc_django.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/httpc_httplib.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/httpc_requests.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/httpc_urllib3.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/logging.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/mod/plugin.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/simple_trace_context.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/trace_context.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/trace_context_manager.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/trace/trace_module_definition.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/bit_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/cardinality/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/cardinality/hyperloglog.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/cardinality/murmurhash.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/cardinality/registerset.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/compare_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/date_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/debug_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/escape_literal_sql.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/hash_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/hexa32.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/int_set.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/ip_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/keygen.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/linked_list.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/linked_map.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/metering_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/request_double_queue.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/request_queue.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/string_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/throttle_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/util/userid_util.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/__init__.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/blob_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/boolean_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/decimal_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/double_summary.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/double_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/float_array.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/float_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/int_array.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/ip4_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/list_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/long_array.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/long_summary.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/map_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/null_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/number_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/summary_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/text_array.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/text_hash_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/text_value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/value.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/value/value_enum.py +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap/whatap.conf +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap_python.egg-info/SOURCES.txt +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap_python.egg-info/dependency_links.txt +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap_python.egg-info/entry_points.txt +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap_python.egg-info/not-zip-safe +0 -0
- {whatap_python-1.7.8 → whatap_python-1.7.9}/whatap_python.egg-info/top_level.txt +0 -0
|
@@ -45,8 +45,17 @@ def instrument(module):
|
|
|
45
45
|
@trace_handler(fn, True)
|
|
46
46
|
@blocking_handler()
|
|
47
47
|
def trace(*args, **kwargs):
|
|
48
|
-
|
|
48
|
+
django_instance = args[0]
|
|
49
|
+
environ = args[1]
|
|
50
|
+
original_start_response = args[2]
|
|
51
|
+
|
|
52
|
+
def custom_start_response(status, response_headers, exc_info=None):
|
|
53
|
+
ctx = TraceContextManager.getLocalContext()
|
|
54
|
+
ctx.status = status[:3]
|
|
55
|
+
return original_start_response(status, response_headers, exc_info)
|
|
49
56
|
|
|
57
|
+
new_args = (django_instance, environ, custom_start_response)
|
|
58
|
+
callback = interceptor(fn, *new_args, **kwargs)
|
|
50
59
|
return callback
|
|
51
60
|
|
|
52
61
|
return trace
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
from whatap.trace.mod.application_wsgi import interceptor, trace_handler, \
|
|
2
2
|
interceptor_error
|
|
3
|
-
|
|
3
|
+
from whatap.trace.trace_context_manager import TraceContextManager
|
|
4
4
|
|
|
5
5
|
def instrument(module):
|
|
6
6
|
def wrapper(fn):
|
|
7
7
|
@trace_handler(fn, True)
|
|
8
8
|
def trace(*args, **kwargs):
|
|
9
|
-
|
|
9
|
+
flask_instance = args[0]
|
|
10
|
+
environ = args[1]
|
|
11
|
+
original_start_response = args[2]
|
|
12
|
+
|
|
13
|
+
def custom_start_response(status, response_headers, exc_info=None):
|
|
14
|
+
ctx = TraceContextManager.getLocalContext()
|
|
15
|
+
ctx.status = status[:3]
|
|
16
|
+
return original_start_response(status, response_headers, exc_info)
|
|
17
|
+
|
|
18
|
+
new_args = (flask_instance, environ, custom_start_response)
|
|
19
|
+
callback = interceptor(fn, *new_args, **kwargs)
|
|
10
20
|
return callback
|
|
11
21
|
|
|
12
22
|
return trace
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import whatap.net.async_sender as async_sender
|
|
3
|
+
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
4
|
+
from whatap.util.userid_util import UseridUtil as userid_util
|
|
5
|
+
from whatap.trace.trace_context import TraceContext
|
|
6
|
+
from whatap.trace.trace_context_manager import TraceContextManager
|
|
7
|
+
from whatap.util.date_util import DateUtil
|
|
8
|
+
from whatap.conf.configure import Configure as conf
|
|
9
|
+
from whatap.trace.mod.application_wsgi import trace_handler, \
|
|
10
|
+
start_interceptor, end_interceptor, interceptor_error, isIgnore
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parseServiceName(environ):
|
|
14
|
+
return environ.get('PATH_INFO', '')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def instrument(module):
|
|
18
|
+
def wrapper(fn):
|
|
19
|
+
async def trace(*args, **kwargs):
|
|
20
|
+
request = args[0].request
|
|
21
|
+
environ = {
|
|
22
|
+
'HTTP_HOST': request.host,
|
|
23
|
+
'PATH_INFO': request.path,
|
|
24
|
+
'QUERY_STRING': request.query_arguments,
|
|
25
|
+
'REMOTE_ADDR': request.remote_ip,
|
|
26
|
+
'HTTP_USER_AGENT': request.headers.get('User-Agent', ''),
|
|
27
|
+
'HTTP_REFERER': request.headers.get('Referer', ''),
|
|
28
|
+
'REQUEST_METHOD': request.method
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
for header_name, value in request.headers.items():
|
|
32
|
+
key = 'HTTP_' + header_name.upper().replace('-', '_')
|
|
33
|
+
environ[key] = value
|
|
34
|
+
|
|
35
|
+
async def run():
|
|
36
|
+
await interceptor((fn, environ), *args, **kwargs)
|
|
37
|
+
|
|
38
|
+
from tornado.ioloop import IOLoop
|
|
39
|
+
IOLoop.current().add_callback(run)
|
|
40
|
+
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
return trace
|
|
44
|
+
|
|
45
|
+
module.RequestHandler._execute = wrapper(module.RequestHandler._execute)
|
|
46
|
+
|
|
47
|
+
def wrapper(fn):
|
|
48
|
+
@trace_handler(fn)
|
|
49
|
+
def trace(*args, **kwargs):
|
|
50
|
+
callback = fn(*args, **kwargs)
|
|
51
|
+
|
|
52
|
+
e = args[1]
|
|
53
|
+
status_code = args[0]._status_code
|
|
54
|
+
errors = [e.__class__.__name__, str(e)]
|
|
55
|
+
interceptor_error(status_code, errors)
|
|
56
|
+
return callback
|
|
57
|
+
|
|
58
|
+
return trace
|
|
59
|
+
|
|
60
|
+
module.RequestHandler._handle_request_exception = wrapper(
|
|
61
|
+
module.RequestHandler._handle_request_exception)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def interceptor(rn_environ, *args, **kwargs):
|
|
65
|
+
if not isinstance(rn_environ, tuple):
|
|
66
|
+
rn_environ = (rn_environ, args[1])
|
|
67
|
+
fn, environ = rn_environ
|
|
68
|
+
|
|
69
|
+
ctx = TraceContext()
|
|
70
|
+
ctx.host = environ.get('HTTP_HOST', '').split(':')[0]
|
|
71
|
+
ctx.service_name = parseServiceName(environ)
|
|
72
|
+
ctx.http_method = environ.get('REQUEST_METHOD', '')
|
|
73
|
+
ctx.remoteIp = userid_util.getRemoteAddr(args)
|
|
74
|
+
ctx.userAgentString = environ.get('HTTP_USER_AGENT', '')
|
|
75
|
+
ctx.referer = environ.get('HTTP_REFERER', '')
|
|
76
|
+
|
|
77
|
+
if conf.trace_user_enabled:
|
|
78
|
+
if conf.trace_user_using_ip:
|
|
79
|
+
ctx.userid = userid_util.getRemoteAddr(args)
|
|
80
|
+
else:
|
|
81
|
+
ctx.userid, ctx._rawuserid = userid_util.getUserId(args, ctx.remoteIp)
|
|
82
|
+
|
|
83
|
+
mstt = environ.get('HTTP_{}'.format(
|
|
84
|
+
conf._trace_mtrace_caller_key.upper().replace('-', '_')), '')
|
|
85
|
+
|
|
86
|
+
if mstt:
|
|
87
|
+
ctx.setTransfer(mstt)
|
|
88
|
+
if conf.stat_mtrace_enabled:
|
|
89
|
+
val = environ.get('HTTP_{}'.format(
|
|
90
|
+
conf._trace_mtrace_info_key.upper().replace('-', '_')), '')
|
|
91
|
+
if val and len(val):
|
|
92
|
+
ctx.setTransferInfo(val)
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
myid = environ.get('HTTP_{}'.format(
|
|
96
|
+
conf._trace_mtrace_callee_key.upper().replace('-', '_')), '')
|
|
97
|
+
if myid:
|
|
98
|
+
ctx.setTxid(myid)
|
|
99
|
+
caller_poid = environ.get('HTTP_{}'.format(
|
|
100
|
+
conf._trace_mtrace_caller_poid_key.upper().replace('-', '_')), '')
|
|
101
|
+
|
|
102
|
+
if caller_poid:
|
|
103
|
+
ctx.mcaller_poid = caller_poid
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
if isIgnore(ctx.service_name):
|
|
107
|
+
ctx.is_ignored = True
|
|
108
|
+
TraceContextManager.end(ctx.id)
|
|
109
|
+
callback = fn(*args, **kwargs)
|
|
110
|
+
if inspect.isawaitable(callback):
|
|
111
|
+
return await callback
|
|
112
|
+
return callback
|
|
113
|
+
except Exception:
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
start_interceptor(ctx)
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
callback = fn(*args, **kwargs)
|
|
120
|
+
if inspect.isawaitable(callback):
|
|
121
|
+
callback = await callback
|
|
122
|
+
|
|
123
|
+
query_string = environ.get('QUERY_STRING', '')
|
|
124
|
+
if query_string:
|
|
125
|
+
ctx.service_name += '?{}'.format(query_string)
|
|
126
|
+
|
|
127
|
+
if ctx.service_name.find('.') > -1 and ctx.service_name.split('.')[
|
|
128
|
+
1] in conf.web_static_content_extensions:
|
|
129
|
+
ctx.isStaticContents = 'true'
|
|
130
|
+
|
|
131
|
+
handler = args[0]
|
|
132
|
+
status_code = getattr(handler, '_status_code', 200)
|
|
133
|
+
if status_code >= 400:
|
|
134
|
+
errors = [
|
|
135
|
+
callback.__class__.__name__ if callback else 'Unknown',
|
|
136
|
+
getattr(callback, 'reason_phrase', '')
|
|
137
|
+
]
|
|
138
|
+
interceptor_error(status_code, errors, ctx=ctx)
|
|
139
|
+
|
|
140
|
+
else:
|
|
141
|
+
ctx.status = status_code
|
|
142
|
+
|
|
143
|
+
if conf.profile_http_header_enabled:
|
|
144
|
+
keys = []
|
|
145
|
+
for key, value in environ.items():
|
|
146
|
+
if key.startswith('HTTP_'):
|
|
147
|
+
keys.append(key)
|
|
148
|
+
keys.sort()
|
|
149
|
+
|
|
150
|
+
text = ''
|
|
151
|
+
for key in keys:
|
|
152
|
+
text += '{}={}\n'.format(key.split('HTTP_')[1].lower(),
|
|
153
|
+
environ[key])
|
|
154
|
+
|
|
155
|
+
datas = ['HTTP-HEADERS', 'HTTP-HEADERS', text]
|
|
156
|
+
ctx.start_time = DateUtil.nowSystem()
|
|
157
|
+
async_sender.send_packet(PacketTypeEnum.TX_MSG, ctx, datas)
|
|
158
|
+
|
|
159
|
+
return callback
|
|
160
|
+
finally:
|
|
161
|
+
end_interceptor(ctx=ctx)
|
|
@@ -10,6 +10,7 @@ from whatap.trace.trace_module_definition import IMPORT_HOOKS, PLUGIN
|
|
|
10
10
|
from whatap import logging
|
|
11
11
|
from whatap.conf.configure import Configure as conf
|
|
12
12
|
|
|
13
|
+
|
|
13
14
|
def load_module(module, fullname):
|
|
14
15
|
# if conf.dev:
|
|
15
16
|
# logging.debug(fullname)
|
|
@@ -36,23 +37,26 @@ def load_module(module, fullname):
|
|
|
36
37
|
finally:
|
|
37
38
|
return module
|
|
38
39
|
|
|
40
|
+
|
|
39
41
|
class _ImportHookLoader(object):
|
|
40
42
|
def load_module(self, fullname):
|
|
41
43
|
module = sys.modules[fullname]
|
|
42
44
|
return load_module(module, fullname)
|
|
43
45
|
|
|
46
|
+
|
|
44
47
|
class _ImportHookChainedLoader(object):
|
|
45
48
|
def __init__(self, loader):
|
|
46
49
|
self.loader = loader
|
|
47
|
-
|
|
50
|
+
|
|
48
51
|
def load_module(self, fullname):
|
|
49
52
|
module = self.loader.load_module(fullname)
|
|
50
53
|
return load_module(module, fullname)
|
|
51
54
|
|
|
55
|
+
|
|
52
56
|
class ImportFinder(object):
|
|
53
57
|
def __init__(self):
|
|
54
58
|
self._hooks = {}
|
|
55
|
-
|
|
59
|
+
|
|
56
60
|
def find_module(self, fullname, path=None):
|
|
57
61
|
if fullname not in IMPORT_HOOKS \
|
|
58
62
|
or fullname.startswith('whatap') \
|
|
@@ -66,10 +70,10 @@ class ImportFinder(object):
|
|
|
66
70
|
if fullname in self._hooks:
|
|
67
71
|
return None
|
|
68
72
|
self._hooks[fullname] = True
|
|
69
|
-
|
|
73
|
+
|
|
70
74
|
# if conf.dev:
|
|
71
75
|
# logging.debug(fullname)
|
|
72
|
-
|
|
76
|
+
|
|
73
77
|
try:
|
|
74
78
|
if find_spec:
|
|
75
79
|
spec = find_spec(fullname, path)
|
|
@@ -78,7 +82,7 @@ class ImportFinder(object):
|
|
|
78
82
|
else:
|
|
79
83
|
__import__(fullname)
|
|
80
84
|
return _ImportHookLoader()
|
|
81
|
-
|
|
85
|
+
|
|
82
86
|
except Exception as e:
|
|
83
87
|
if conf.dev:
|
|
84
88
|
print(e)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from whatap.trace.mod.application_wsgi import trace_handler, \
|
|
2
|
-
interceptor, interceptor_error
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def instrument(module):
|
|
6
|
-
def wrapper(fn):
|
|
7
|
-
@trace_handler(fn, True)
|
|
8
|
-
def trace(*args, **kwargs):
|
|
9
|
-
request = args[0].request
|
|
10
|
-
|
|
11
|
-
environ = dict()
|
|
12
|
-
environ['HTTP_HOST'] = request.host
|
|
13
|
-
environ['PATH_INFO'] = request.path
|
|
14
|
-
environ['QUERY_STRING'] = request.query_arguments
|
|
15
|
-
environ['REMOTE_ADDR'] = request.remote_ip
|
|
16
|
-
environ['HTTP_USER_AGENT'] = request.headers.get('User-Agent', '')
|
|
17
|
-
environ['HTTP_REFERER'] = ''
|
|
18
|
-
|
|
19
|
-
callback = interceptor((fn, environ), *args, **kwargs)
|
|
20
|
-
|
|
21
|
-
return callback
|
|
22
|
-
|
|
23
|
-
return trace
|
|
24
|
-
|
|
25
|
-
module.RequestHandler._execute = wrapper(module.RequestHandler._execute)
|
|
26
|
-
|
|
27
|
-
def wrapper(fn):
|
|
28
|
-
@trace_handler(fn)
|
|
29
|
-
def trace(*args, **kwargs):
|
|
30
|
-
callback = fn(*args, **kwargs)
|
|
31
|
-
|
|
32
|
-
e = args[1]
|
|
33
|
-
status_code = args[0]._status_code
|
|
34
|
-
errors = [e.__class__.__name__, str(e)]
|
|
35
|
-
interceptor_error(status_code, errors)
|
|
36
|
-
return callback
|
|
37
|
-
|
|
38
|
-
return trace
|
|
39
|
-
|
|
40
|
-
module.RequestHandler._handle_request_exception = wrapper(
|
|
41
|
-
module.RequestHandler._handle_request_exception)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|