whatap-python 1.7.6__tar.gz → 1.7.7__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.
- {whatap_python-1.7.6 → whatap_python-1.7.7}/PKG-INFO +1 -1
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/__init__.py +34 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/agent/linux/amd64/whatap_python +0 -0
- whatap_python-1.7.7/whatap/build.py +4 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/conf/configuration.py +1 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_wsgi.py +22 -3
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/database_cxoracle.py +26 -6
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/database_mysql.py +23 -19
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/database_postgresql.py +11 -9
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/database_toolkit.py +13 -3
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/trace_context.py +4 -1
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap_python.egg-info/PKG-INFO +1 -1
- whatap_python-1.7.6/whatap/build.py +0 -4
- {whatap_python-1.7.6 → whatap_python-1.7.7}/README.md +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/setup.cfg +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/setup.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/LICENSE +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/README.rst +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/__main__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/agent/darwin/amd64/whatap_python +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/agent/darwin/arm64/whatap_python +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/agent/linux/arm64/whatap_python +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/bootstrap/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/bootstrap/sitecustomize.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/conf/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/conf/configure.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/conf/license.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/control/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/counter/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/counter/counter_manager.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/counter/tasks/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/counter/tasks/openfiledescriptor.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/io/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/io/data_inputx.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/io/data_outputx.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/async_sender.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/packet_enum.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/packet_type_enum.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/param_def.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/stackhelper.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/udp_session.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/net/udp_thread.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/pack/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/pack/logSinkPack.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/pack/pack.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/pack/pack_enum.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/pack/tagCountPack.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/scripts/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/amqp_kombu.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/amqp_pika.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_bottle.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_celery.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_cherrypy.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_django.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_django_asgi.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_django_py3.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_fastapi.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_flask.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_frappe.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_graphql.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_nameko.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/application_tornado.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/database_mongo.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/database_redis.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/email_smtp.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/httpc_django.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/httpc_httplib.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/httpc_requests.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/httpc_urllib3.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/logging.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/mod/plugin.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/simple_trace_context.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/trace_context_manager.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/trace_import.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/trace/trace_module_definition.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/bit_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/cardinality/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/cardinality/hyperloglog.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/cardinality/murmurhash.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/cardinality/registerset.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/compare_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/date_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/debug_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/escape_literal_sql.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/hash_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/hexa32.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/int_set.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/ip_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/keygen.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/linked_list.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/linked_map.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/metering_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/request_double_queue.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/request_queue.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/string_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/throttle_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/util/userid_util.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/__init__.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/blob_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/boolean_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/decimal_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/double_summary.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/double_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/float_array.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/float_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/int_array.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/ip4_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/list_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/long_array.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/long_summary.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/map_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/null_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/number_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/summary_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/text_array.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/text_hash_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/text_value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/value.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/value/value_enum.py +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap/whatap.conf +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap_python.egg-info/SOURCES.txt +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap_python.egg-info/dependency_links.txt +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap_python.egg-info/entry_points.txt +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap_python.egg-info/not-zip-safe +0 -0
- {whatap_python-1.7.6 → whatap_python-1.7.7}/whatap_python.egg-info/top_level.txt +0 -0
|
@@ -7,6 +7,8 @@ import time
|
|
|
7
7
|
from whatap import build
|
|
8
8
|
from whatap.util.date_util import DateUtil
|
|
9
9
|
import threading
|
|
10
|
+
import builtins
|
|
11
|
+
import configparser
|
|
10
12
|
|
|
11
13
|
__version__ = build.version
|
|
12
14
|
|
|
@@ -47,6 +49,38 @@ LOG_FILE_NAME = 'whatap-hook.log'
|
|
|
47
49
|
|
|
48
50
|
isFrappeCommands = "get-frappe-commands" in sys.argv if hasattr(sys, "argv") else False
|
|
49
51
|
|
|
52
|
+
temporary_config = configparser.ConfigParser()
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
if os.path.exists('whatap.conf'):
|
|
56
|
+
with open('whatap.conf') as f:
|
|
57
|
+
file_content = f.read()
|
|
58
|
+
temporary_file_content = '[dummy_section]\n' + file_content
|
|
59
|
+
temporary_config.read_string(temporary_file_content)
|
|
60
|
+
console_option = temporary_config.get('dummy_section', 'ignore_whatap_stdout', fallback='false')
|
|
61
|
+
else:
|
|
62
|
+
console_option = 'false'
|
|
63
|
+
except Exception as e:
|
|
64
|
+
print('WHATAP : WHATAP.CONF READ ERROR')
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
original_print = builtins.print
|
|
69
|
+
|
|
70
|
+
def print_option(func):
|
|
71
|
+
def wrapper(*args, **kwargs):
|
|
72
|
+
|
|
73
|
+
if(console_option == 'false'):
|
|
74
|
+
result = func(*args, **kwargs)
|
|
75
|
+
else:
|
|
76
|
+
result = None
|
|
77
|
+
return result
|
|
78
|
+
return wrapper
|
|
79
|
+
|
|
80
|
+
__builtins__ = dict(__builtins__)
|
|
81
|
+
__builtins__['print'] = print_option(original_print)
|
|
82
|
+
|
|
83
|
+
|
|
50
84
|
def whatap_print(*args):
|
|
51
85
|
if isFrappeCommands:
|
|
52
86
|
logging.info(*args)
|
|
Binary file
|
|
@@ -382,7 +382,7 @@ def interceptor_sock_connect(fn, *args, **kwargs):
|
|
|
382
382
|
ctx.socket_connecting = False
|
|
383
383
|
|
|
384
384
|
|
|
385
|
-
def interceptor_db_con(fn,
|
|
385
|
+
def interceptor_db_con(fn, db_info, *args, **kwargs):
|
|
386
386
|
ctx = TraceContextManager.getLocalContext()
|
|
387
387
|
if not ctx:
|
|
388
388
|
return fn(*args, **kwargs)
|
|
@@ -399,7 +399,8 @@ def interceptor_db_con(fn, db_type, *args, **kwargs):
|
|
|
399
399
|
if not kwargs:
|
|
400
400
|
kwargs = dict(
|
|
401
401
|
x.split('=') for x in re.sub(r'\s*=\s*', '=', args[0]).split())
|
|
402
|
-
|
|
402
|
+
|
|
403
|
+
text = '{}://'.format(db_info.get('type'))
|
|
403
404
|
text += kwargs.get('user')
|
|
404
405
|
text += "@"
|
|
405
406
|
text += kwargs.get('host', kwargs.get('dsn', ''))
|
|
@@ -441,7 +442,7 @@ def addQuoteList(arg_list):
|
|
|
441
442
|
return tuple(quoted_list)
|
|
442
443
|
|
|
443
444
|
|
|
444
|
-
def interceptor_db_execute(fn, *args, **kwargs):
|
|
445
|
+
def interceptor_db_execute(fn, db_info, *args, **kwargs):
|
|
445
446
|
ctx = TraceContextManager.getLocalContext()
|
|
446
447
|
# sendDebugProfile(ctx, 'interceptor_db_execute step -1')
|
|
447
448
|
self = args[0]
|
|
@@ -465,6 +466,24 @@ def interceptor_db_execute(fn, *args, **kwargs):
|
|
|
465
466
|
if not query:
|
|
466
467
|
return fn(*args, **kwargs)
|
|
467
468
|
|
|
469
|
+
start_time = DateUtil.nowSystem()
|
|
470
|
+
ctx.start_time = start_time
|
|
471
|
+
|
|
472
|
+
text = '{}://'.format(db_info.get('type'))
|
|
473
|
+
text += db_info.get('user')
|
|
474
|
+
text += "@"
|
|
475
|
+
text += db_info.get('host', db_info.get('dsn', ''))
|
|
476
|
+
text += '/'
|
|
477
|
+
text += db_info.get('database', db_info.get('db', db_info.get('dbname', '')))
|
|
478
|
+
ctx.active_dbc = text
|
|
479
|
+
ctx.lctx['dbc'] = text
|
|
480
|
+
|
|
481
|
+
ctx.active_dbc = 0
|
|
482
|
+
|
|
483
|
+
datas = [text]
|
|
484
|
+
ctx.elapsed = DateUtil.nowSystem() - start_time
|
|
485
|
+
async_sender.send_packet(PacketTypeEnum.TX_DB_CONN, ctx, datas)
|
|
486
|
+
|
|
468
487
|
start_time = DateUtil.nowSystem()
|
|
469
488
|
ctx.start_time = start_time
|
|
470
489
|
ctx.active_sqlhash = query
|
|
@@ -2,27 +2,47 @@ from whatap.trace import get_dict
|
|
|
2
2
|
from whatap.trace.mod.application_wsgi import trace_handler, \
|
|
3
3
|
interceptor_db_con, interceptor_db_execute, interceptor_db_close
|
|
4
4
|
|
|
5
|
+
db_info = {}
|
|
6
|
+
|
|
7
|
+
|
|
5
8
|
def instrument_oracle_client(module):
|
|
9
|
+
|
|
6
10
|
def wrapper(fn):
|
|
7
11
|
@trace_handler(fn)
|
|
8
12
|
def trace(*args, **kwargs):
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
global db_info
|
|
14
|
+
db_info = {'type': 'oracle'} | kwargs
|
|
15
|
+
|
|
16
|
+
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
11
17
|
return callback
|
|
12
|
-
|
|
18
|
+
|
|
13
19
|
return trace
|
|
20
|
+
|
|
14
21
|
if hasattr(module, "connect"):
|
|
15
22
|
module.connect = wrapper(module.connect)
|
|
16
|
-
|
|
23
|
+
|
|
17
24
|
def wrapper(fn):
|
|
18
25
|
@trace_handler(fn)
|
|
19
26
|
def trace(*args, **kwargs):
|
|
20
27
|
callback = interceptor_db_close(fn, *args, **kwargs)
|
|
21
28
|
return callback
|
|
22
|
-
|
|
29
|
+
|
|
23
30
|
return trace
|
|
24
|
-
|
|
31
|
+
|
|
25
32
|
if hasattr(module, "Connection") and hasattr(module.Connection, "close"):
|
|
26
33
|
get_dict(module.Connection)['close'] = wrapper(
|
|
27
34
|
module.Connection.close)
|
|
28
35
|
|
|
36
|
+
# def wrapper(fn):
|
|
37
|
+
# @trace_handler(fn)
|
|
38
|
+
# def trace(*args, **kwargs):
|
|
39
|
+
# callback = interceptor_db_execute(fn, db_info, *args, **kwargs)
|
|
40
|
+
# return callback
|
|
41
|
+
#
|
|
42
|
+
# return trace
|
|
43
|
+
#
|
|
44
|
+
# if hasattr(module, 'Cursor') and hasattr(module.Cursor, "execute"):
|
|
45
|
+
# get_dict(module.Cursor)['execute'] = wrapper(module.Cursor.execute)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
@@ -2,27 +2,30 @@ from whatap.trace import get_dict
|
|
|
2
2
|
from whatap.trace.mod.application_wsgi import trace_handler, \
|
|
3
3
|
interceptor_db_con, interceptor_db_execute, interceptor_db_close
|
|
4
4
|
|
|
5
|
+
db_info = {}
|
|
5
6
|
|
|
6
7
|
def instrument_MySQLdb(module):
|
|
7
8
|
def wrapper(fn):
|
|
8
9
|
@trace_handler(fn)
|
|
9
10
|
def trace(*args, **kwargs):
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
global db_info
|
|
12
|
+
db_info = {'type': 'mysql'} | kwargs
|
|
13
|
+
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
12
14
|
return callback
|
|
13
|
-
|
|
15
|
+
|
|
14
16
|
return trace
|
|
17
|
+
|
|
15
18
|
if hasattr(module, "connect"):
|
|
16
19
|
module.connect = wrapper(module.connect)
|
|
17
|
-
|
|
20
|
+
|
|
18
21
|
def wrapper(fn):
|
|
19
22
|
@trace_handler(fn)
|
|
20
23
|
def trace(*args, **kwargs):
|
|
21
24
|
callback = interceptor_db_close(fn, *args, **kwargs)
|
|
22
25
|
return callback
|
|
23
|
-
|
|
26
|
+
|
|
24
27
|
return trace
|
|
25
|
-
|
|
28
|
+
|
|
26
29
|
if hasattr(module, "connection") and hasattr(module.connection, "close"):
|
|
27
30
|
get_dict(module.connection)['close'] = wrapper(
|
|
28
31
|
module.connection.close)
|
|
@@ -32,35 +35,36 @@ def instrument_MySQLdb_cursors(module):
|
|
|
32
35
|
def wrapper(fn):
|
|
33
36
|
@trace_handler(fn)
|
|
34
37
|
def trace(*args, **kwargs):
|
|
35
|
-
callback = interceptor_db_execute(fn, *args, **kwargs)
|
|
38
|
+
callback = interceptor_db_execute(fn, db_info, *args, **kwargs)
|
|
36
39
|
return callback
|
|
37
|
-
|
|
40
|
+
|
|
38
41
|
return trace
|
|
39
|
-
|
|
42
|
+
|
|
40
43
|
module.BaseCursor.execute = wrapper(module.BaseCursor.execute)
|
|
41
|
-
if hasattr(module.BaseCursor,'callproc'):
|
|
42
|
-
module.BaseCursor.callproc= wrapper(module.BaseCursor.callproc)
|
|
44
|
+
if hasattr(module.BaseCursor, 'callproc'):
|
|
45
|
+
module.BaseCursor.callproc = wrapper(module.BaseCursor.callproc)
|
|
43
46
|
|
|
44
47
|
def instrument_pymysql(module):
|
|
45
48
|
def wrapper(fn):
|
|
46
49
|
@trace_handler(fn)
|
|
47
50
|
def trace(*args, **kwargs):
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
global db_info
|
|
52
|
+
db_info = {'type': 'mysql'} | kwargs
|
|
53
|
+
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
50
54
|
return callback
|
|
51
|
-
|
|
55
|
+
|
|
52
56
|
return trace
|
|
53
|
-
|
|
57
|
+
|
|
54
58
|
module.connect = wrapper(module.connect)
|
|
55
|
-
|
|
59
|
+
|
|
56
60
|
def wrapper(fn):
|
|
57
61
|
@trace_handler(fn)
|
|
58
62
|
def trace(*args, **kwargs):
|
|
59
63
|
callback = interceptor_db_close(fn, *args, **kwargs)
|
|
60
64
|
return callback
|
|
61
|
-
|
|
65
|
+
|
|
62
66
|
return trace
|
|
63
|
-
|
|
67
|
+
|
|
64
68
|
module.connections.Connection.close = wrapper(
|
|
65
69
|
module.connections.Connection.close)
|
|
66
70
|
|
|
@@ -68,7 +72,7 @@ def instrument_pymysql_cursors(module):
|
|
|
68
72
|
def wrapper(fn):
|
|
69
73
|
@trace_handler(fn)
|
|
70
74
|
def trace(*args, **kwargs):
|
|
71
|
-
callback = interceptor_db_execute(fn, *args, **kwargs)
|
|
75
|
+
callback = interceptor_db_execute(fn, db_info, *args, **kwargs)
|
|
72
76
|
return callback
|
|
73
77
|
|
|
74
78
|
return trace
|
|
@@ -2,17 +2,19 @@ from whatap.trace import get_dict
|
|
|
2
2
|
from whatap.trace.mod.application_wsgi import trace_handler, \
|
|
3
3
|
interceptor_db_con, interceptor_db_execute, interceptor_db_close
|
|
4
4
|
|
|
5
|
+
db_info = {}
|
|
5
6
|
|
|
6
7
|
def instrument_psycopg2(module):
|
|
7
8
|
def wrapper(fn):
|
|
8
9
|
@trace_handler(fn)
|
|
9
10
|
def trace(*args, **kwargs):
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
global db_info
|
|
12
|
+
db_info = {'type': 'postgresql'} | kwargs
|
|
13
|
+
callback = interceptor_db_con(fn, db_info, *args, **kwargs)
|
|
12
14
|
return callback
|
|
13
|
-
|
|
15
|
+
|
|
14
16
|
return trace
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
module.connect = wrapper(module.connect)
|
|
17
19
|
|
|
18
20
|
|
|
@@ -22,9 +24,9 @@ def instrument_psycopg2_connection(module):
|
|
|
22
24
|
def trace(*args, **kwargs):
|
|
23
25
|
callback = interceptor_db_close(fn, *args, **kwargs)
|
|
24
26
|
return callback
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
return trace
|
|
27
|
-
|
|
29
|
+
|
|
28
30
|
get_dict(module.connection)['close'] = wrapper(module.connection.close)
|
|
29
31
|
|
|
30
32
|
|
|
@@ -32,9 +34,9 @@ def instrument_psycopg2_extensions(module):
|
|
|
32
34
|
def wrapper(fn):
|
|
33
35
|
@trace_handler(fn)
|
|
34
36
|
def trace(*args, **kwargs):
|
|
35
|
-
callback = interceptor_db_execute(fn, *args, **kwargs)
|
|
37
|
+
callback = interceptor_db_execute(fn, db_info, *args, **kwargs)
|
|
36
38
|
return callback
|
|
37
|
-
|
|
39
|
+
|
|
38
40
|
return trace
|
|
39
|
-
|
|
41
|
+
|
|
40
42
|
get_dict(module.cursor)['execute'] = wrapper(module.cursor.execute)
|
|
@@ -47,16 +47,26 @@ def instrument_sqlalchemy_engine(module):
|
|
|
47
47
|
ctx = TraceContextManager.getLocalContext()
|
|
48
48
|
cursor = args[1]
|
|
49
49
|
query = None
|
|
50
|
-
if len(args) > 3 and
|
|
50
|
+
if len(args) > 3 and args[3]:
|
|
51
51
|
try:
|
|
52
52
|
##oracledb 에서 orm 툴로 sqlalchemy 사용하는 경우
|
|
53
|
-
if ":" in args[2] and "oracle" in str(args[0]):
|
|
53
|
+
if (type(args[3]) == dict) and (":" in args[2]) and ("oracle" in str(args[0])):
|
|
54
54
|
oracle_sql_query = args[2]
|
|
55
55
|
for k, v in args[3].items():
|
|
56
56
|
replaced_key = f":{k}"
|
|
57
57
|
replaced_value = f"'{v}'"
|
|
58
|
-
oracle_sql_query = oracle_sql_query.replace(replaced_key,
|
|
58
|
+
oracle_sql_query = oracle_sql_query.replace(replaced_key,
|
|
59
|
+
replaced_value) if replaced_key in oracle_sql_query else None
|
|
59
60
|
query = oracle_sql_query
|
|
61
|
+
|
|
62
|
+
##aiomysql 에서 orm 툴로 sqlalchemy 사용하는 경우
|
|
63
|
+
elif (type(args[3]) == tuple) and ("%s" in args[2]) and ("aiomysql" in str(args[0])):
|
|
64
|
+
my_sql_query = args[2]
|
|
65
|
+
for v in args[3]:
|
|
66
|
+
replaced_value = f"'{v}'"
|
|
67
|
+
my_sql_query = my_sql_query.replace("%s", replaced_value,
|
|
68
|
+
1) if "%s" in my_sql_query else None
|
|
69
|
+
query = my_sql_query
|
|
60
70
|
else:
|
|
61
71
|
query = args[2] % addQuote(args[3])
|
|
62
72
|
except Exception as e:
|
|
@@ -5,6 +5,7 @@ from whatap.conf.configure import Configure as conf
|
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
6
6
|
from whatap.util.date_util import DateUtil
|
|
7
7
|
from whatap.util.hexa32 import Hexa32
|
|
8
|
+
from whatap.util.hash_util import HashUtil
|
|
8
9
|
|
|
9
10
|
from whatap.util.linked_map import LinkedMap
|
|
10
11
|
from resource import getrusage, RUSAGE_SELF
|
|
@@ -166,6 +167,8 @@ class TraceContext(object):
|
|
|
166
167
|
def transferPOID(self):
|
|
167
168
|
if not self.transfer_poid:
|
|
168
169
|
self.transfer_poid = ",".join(
|
|
169
|
-
(Hexa32.toString32(conf.PCODE),
|
|
170
|
+
(Hexa32.toString32(conf.PCODE),
|
|
171
|
+
Hexa32.toString32(HashUtil.hashFromString(conf.OKIND) if isinstance(conf.OKIND, str) else conf.OKIND),
|
|
172
|
+
Hexa32.toString32(int(conf.OID))))
|
|
170
173
|
|
|
171
174
|
return self.transfer_poid
|
|
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
|