whatap-python 1.7.7__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.7 → whatap_python-1.7.9}/PKG-INFO +1 -1
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/agent/darwin/amd64/whatap_python +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/agent/darwin/arm64/whatap_python +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/agent/linux/amd64/whatap_python +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/agent/linux/arm64/whatap_python +0 -0
- whatap_python-1.7.9/whatap/build.py +4 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/packet_enum.py +1 -1
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_django.py +10 -1
- {whatap_python-1.7.7 → 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.7 → whatap_python-1.7.9}/whatap/trace/mod/application_wsgi.py +10 -7
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/database_cxoracle.py +2 -2
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/database_mysql.py +4 -2
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/database_postgresql.py +2 -1
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/trace_import.py +9 -5
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap_python.egg-info/PKG-INFO +1 -1
- whatap_python-1.7.7/whatap/build.py +0 -4
- whatap_python-1.7.7/whatap/trace/mod/application_tornado.py +0 -41
- {whatap_python-1.7.7 → whatap_python-1.7.9}/README.md +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/setup.cfg +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/setup.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/LICENSE +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/README.rst +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/__main__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/bootstrap/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/bootstrap/sitecustomize.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/conf/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/conf/configuration.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/conf/configure.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/conf/license.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/control/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/counter/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/counter/counter_manager.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/counter/tasks/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/counter/tasks/openfiledescriptor.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/io/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/io/data_inputx.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/io/data_outputx.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/async_sender.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/packet_type_enum.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/param_def.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/stackhelper.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/udp_session.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/net/udp_thread.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/pack/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/pack/logSinkPack.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/pack/pack.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/pack/pack_enum.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/pack/tagCountPack.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/scripts/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/amqp_kombu.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/amqp_pika.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_bottle.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_celery.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_cherrypy.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_django_asgi.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_django_py3.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_fastapi.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_frappe.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_graphql.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/application_nameko.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/database_mongo.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/database_redis.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/database_toolkit.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/email_smtp.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/httpc_django.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/httpc_httplib.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/httpc_requests.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/httpc_urllib3.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/logging.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/mod/plugin.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/simple_trace_context.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/trace_context.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/trace_context_manager.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/trace/trace_module_definition.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/bit_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/cardinality/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/cardinality/hyperloglog.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/cardinality/murmurhash.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/cardinality/registerset.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/compare_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/date_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/debug_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/escape_literal_sql.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/hash_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/hexa32.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/int_set.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/ip_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/keygen.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/linked_list.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/linked_map.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/metering_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/request_double_queue.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/request_queue.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/string_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/throttle_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/util/userid_util.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/__init__.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/blob_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/boolean_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/decimal_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/double_summary.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/double_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/float_array.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/float_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/int_array.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/ip4_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/list_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/long_array.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/long_summary.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/map_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/null_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/number_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/summary_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/text_array.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/text_hash_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/text_value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/value.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/value/value_enum.py +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap/whatap.conf +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap_python.egg-info/SOURCES.txt +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap_python.egg-info/dependency_links.txt +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap_python.egg-info/entry_points.txt +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap_python.egg-info/not-zip-safe +0 -0
- {whatap_python-1.7.7 → whatap_python-1.7.9}/whatap_python.egg-info/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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)
|
|
@@ -96,7 +96,8 @@ def start_interceptor(ctx):
|
|
|
96
96
|
ctx.userAgentString,
|
|
97
97
|
ctx.referer,
|
|
98
98
|
ctx.userid,
|
|
99
|
-
ctx.isStaticContents
|
|
99
|
+
ctx.isStaticContents,
|
|
100
|
+
ctx.http_method
|
|
100
101
|
]
|
|
101
102
|
# print("start_interceptor txid:", ctx.id)
|
|
102
103
|
async_sender.send_packet(PacketTypeEnum.TX_START, ctx, datas)
|
|
@@ -121,7 +122,7 @@ def end_interceptor(thread_id=None, ctx=None):
|
|
|
121
122
|
ctx.start_time = start_time
|
|
122
123
|
|
|
123
124
|
datas = [ctx.host, ctx.service_name, ctx.mtid, ctx.mdepth, ctx.mcaller_txid,
|
|
124
|
-
ctx.mcaller_pcode, ctx.mcaller_spec, str(ctx.mcaller_url_hash), ctx.mcaller_poid]
|
|
125
|
+
ctx.mcaller_pcode, ctx.mcaller_spec, str(ctx.mcaller_url_hash), ctx.mcaller_poid,ctx.status]
|
|
125
126
|
ctx.elapsed = DateUtil.nowSystem() - start_time
|
|
126
127
|
|
|
127
128
|
async_sender.send_packet(PacketTypeEnum.TX_END, ctx, datas)
|
|
@@ -149,7 +150,7 @@ def interceptor(rn_environ, *args, **kwargs):
|
|
|
149
150
|
ctx = TraceContext()
|
|
150
151
|
ctx.host = environ.get('HTTP_HOST', '').split(':')[0]
|
|
151
152
|
ctx.service_name = parseServiceName(environ)
|
|
152
|
-
|
|
153
|
+
ctx.http_method = environ.get('REQUEST_METHOD', '')
|
|
153
154
|
ctx.remoteIp = userid_util.getRemoteAddr(args)
|
|
154
155
|
|
|
155
156
|
ctx.userAgentString = environ.get('HTTP_USER_AGENT', '')
|
|
@@ -206,8 +207,10 @@ def interceptor(rn_environ, *args, **kwargs):
|
|
|
206
207
|
|
|
207
208
|
if getattr(callback, 'status_code', None):
|
|
208
209
|
status_code = callback.status_code
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
|
|
211
|
+
if (status_code >= 400):
|
|
212
|
+
errors = [callback.__class__.__name__, callback.reason_phrase]
|
|
213
|
+
interceptor_error(status_code, errors, ctx=ctx)
|
|
211
214
|
|
|
212
215
|
if conf.profile_http_header_enabled:
|
|
213
216
|
keys = []
|
|
@@ -234,8 +237,8 @@ def interceptor_error(status_code, errors, ctx=None):
|
|
|
234
237
|
ctx = TraceContextManager.getLocalContext()
|
|
235
238
|
if not ctx:
|
|
236
239
|
return
|
|
237
|
-
ctx.status =
|
|
238
|
-
if
|
|
240
|
+
ctx.status = status_code
|
|
241
|
+
if status_code >= 400 and not ctx.error:
|
|
239
242
|
ctx.error = 1
|
|
240
243
|
|
|
241
244
|
error = ''
|
|
@@ -11,8 +11,8 @@ def instrument_oracle_client(module):
|
|
|
11
11
|
@trace_handler(fn)
|
|
12
12
|
def trace(*args, **kwargs):
|
|
13
13
|
global db_info
|
|
14
|
-
db_info = {'type': 'oracle'}
|
|
15
|
-
|
|
14
|
+
db_info = {'type': 'oracle'}
|
|
15
|
+
db_info.update(kwargs)
|
|
16
16
|
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
17
17
|
return callback
|
|
18
18
|
|
|
@@ -9,7 +9,8 @@ def instrument_MySQLdb(module):
|
|
|
9
9
|
@trace_handler(fn)
|
|
10
10
|
def trace(*args, **kwargs):
|
|
11
11
|
global db_info
|
|
12
|
-
db_info = {'type': 'mysql'}
|
|
12
|
+
db_info = {'type': 'mysql'}
|
|
13
|
+
db_info.update(kwargs)
|
|
13
14
|
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
14
15
|
return callback
|
|
15
16
|
|
|
@@ -49,7 +50,8 @@ def instrument_pymysql(module):
|
|
|
49
50
|
@trace_handler(fn)
|
|
50
51
|
def trace(*args, **kwargs):
|
|
51
52
|
global db_info
|
|
52
|
-
db_info = {'type': 'mysql'}
|
|
53
|
+
db_info = {'type': 'mysql'}
|
|
54
|
+
db_info.update(kwargs)
|
|
53
55
|
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
54
56
|
return callback
|
|
55
57
|
|
|
@@ -9,7 +9,8 @@ def instrument_psycopg2(module):
|
|
|
9
9
|
@trace_handler(fn)
|
|
10
10
|
def trace(*args, **kwargs):
|
|
11
11
|
global db_info
|
|
12
|
-
db_info = {'type': 'postgresql'}
|
|
12
|
+
db_info = {'type': 'postgresql'}
|
|
13
|
+
db_info.update(kwargs)
|
|
13
14
|
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
14
15
|
return callback
|
|
15
16
|
|
|
@@ -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
|