whatap-python 1.8.5__tar.gz → 1.8.14__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.8.5 → whatap_python-1.8.14}/PKG-INFO +1 -1
- {whatap_python-1.8.5 → whatap_python-1.8.14}/setup.py +1 -1
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/__init__.py +31 -13
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/agent/darwin/amd64/whatap_python +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/agent/darwin/arm64/whatap_python +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/agent/linux/amd64/whatap_python +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/agent/linux/arm64/whatap_python +0 -0
- whatap_python-1.8.14/whatap/build.py +4 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/conf/configuration.py +12 -1
- whatap_python-1.8.14/whatap/counter/__init__.py +9 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/counter/counter_manager.py +12 -5
- whatap_python-1.8.14/whatap/counter/tasks/llm_stat.py +111 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/udp_session.py +0 -3
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/scripts/__init__.py +5 -1
- whatap_python-1.8.5/whatap/trace/mod/amqp_kombu.py → whatap_python-1.8.14/whatap/trace/mod/amqp/kombu.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/amqp_pika.py → whatap_python-1.8.14/whatap/trace/mod/amqp/pika.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_bottle.py → whatap_python-1.8.14/whatap/trace/mod/application/bottle.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_celery.py → whatap_python-1.8.14/whatap/trace/mod/application/celery.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_cherrypy.py → whatap_python-1.8.14/whatap/trace/mod/application/cherrypy.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_django.py → whatap_python-1.8.14/whatap/trace/mod/application/django.py +3 -3
- whatap_python-1.8.5/whatap/trace/mod/application_django_asgi.py → whatap_python-1.8.14/whatap/trace/mod/application/django_asgi.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_django_py3.py → whatap_python-1.8.14/whatap/trace/mod/application/django_py3.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_fastapi.py → whatap_python-1.8.14/whatap/trace/mod/application/fastapi.py +2 -1
- whatap_python-1.8.5/whatap/trace/mod/application_flask.py → whatap_python-1.8.14/whatap/trace/mod/application/flask.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_frappe.py → whatap_python-1.8.14/whatap/trace/mod/application/frappe.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_graphql.py → whatap_python-1.8.14/whatap/trace/mod/application/graphql.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_nameko.py → whatap_python-1.8.14/whatap/trace/mod/application/nameko.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_odoo.py → whatap_python-1.8.14/whatap/trace/mod/application/odoo.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_starlette.py → whatap_python-1.8.14/whatap/trace/mod/application/starlette.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_tornado.py → whatap_python-1.8.14/whatap/trace/mod/application/tornado.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/application_wsgi.py → whatap_python-1.8.14/whatap/trace/mod/application/wsgi.py +31 -170
- whatap_python-1.8.14/whatap/trace/mod/database/__init__.py +0 -0
- whatap_python-1.8.5/whatap/trace/mod/database_cxoracle.py → whatap_python-1.8.14/whatap/trace/mod/database/cxoracle.py +2 -2
- whatap_python-1.8.5/whatap/trace/mod/database_mongo.py → whatap_python-1.8.14/whatap/trace/mod/database/mongo.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/database_mysql.py → whatap_python-1.8.14/whatap/trace/mod/database/mysql.py +2 -3
- whatap_python-1.8.14/whatap/trace/mod/database/neo4j.py +90 -0
- whatap_python-1.8.5/whatap/trace/mod/database_postgresql.py → whatap_python-1.8.14/whatap/trace/mod/database/psycopg2.py +2 -2
- whatap_python-1.8.14/whatap/trace/mod/database/psycopg3.py +359 -0
- whatap_python-1.8.5/whatap/trace/mod/database_redis.py → whatap_python-1.8.14/whatap/trace/mod/database/redis.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/database_toolkit.py → whatap_python-1.8.14/whatap/trace/mod/database/sqlalchemy.py +5 -5
- whatap_python-1.8.14/whatap/trace/mod/database/sqlite3.py +130 -0
- whatap_python-1.8.14/whatap/trace/mod/database/util.py +577 -0
- whatap_python-1.8.14/whatap/trace/mod/email/__init__.py +0 -0
- whatap_python-1.8.5/whatap/trace/mod/email_smtp.py → whatap_python-1.8.14/whatap/trace/mod/email/smtp.py +1 -1
- whatap_python-1.8.14/whatap/trace/mod/httpc/__init__.py +0 -0
- whatap_python-1.8.5/whatap/trace/mod/httpc_django.py → whatap_python-1.8.14/whatap/trace/mod/httpc/django.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/httpc_httplib.py → whatap_python-1.8.14/whatap/trace/mod/httpc/httplib.py +1 -1
- whatap_python-1.8.14/whatap/trace/mod/httpc/httpx.py +36 -0
- whatap_python-1.8.5/whatap/trace/mod/httpc_requests.py → whatap_python-1.8.14/whatap/trace/mod/httpc/requests.py +1 -1
- whatap_python-1.8.5/whatap/trace/mod/httpc_urllib3.py → whatap_python-1.8.14/whatap/trace/mod/httpc/urllib3.py +1 -1
- whatap_python-1.8.14/whatap/trace/mod/llm/__init__.py +0 -0
- whatap_python-1.8.14/whatap/trace/mod/llm/openai.py +223 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/mod/plugin.py +1 -1
- whatap_python-1.8.14/whatap/trace/mod/standalone/__init__.py +0 -0
- whatap_python-1.8.14/whatap/trace/mod/standalone/multiple.py +278 -0
- whatap_python-1.8.14/whatap/trace/mod/standalone/single.py +123 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/trace_module_definition.py +70 -40
- whatap_python-1.8.14/whatap/util/__init__.py +0 -0
- whatap_python-1.8.14/whatap/util/cardinality/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap_python.egg-info/PKG-INFO +1 -1
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap_python.egg-info/SOURCES.txt +44 -28
- whatap_python-1.8.5/whatap/build.py +0 -4
- whatap_python-1.8.5/whatap/counter/__init__.py +0 -6
- {whatap_python-1.8.5 → whatap_python-1.8.14}/README.md +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/setup.cfg +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/LICENSE +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/README.rst +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/__main__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/bootstrap/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/bootstrap/sitecustomize.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/conf/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/conf/configure.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/conf/license.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/control/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/counter/tasks/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/counter/tasks/openfiledescriptor.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/io/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/io/data_inputx.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/io/data_outputx.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/async_sender.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/packet_enum.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/packet_type_enum.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/param_def.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/stackhelper.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/net/udp_thread.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/pack/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/pack/logSinkPack.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/pack/pack.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/pack/pack_enum.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/pack/tagCountPack.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/mod/__init__.py +0 -0
- {whatap_python-1.8.5/whatap/util → whatap_python-1.8.14/whatap/trace/mod/amqp}/__init__.py +0 -0
- {whatap_python-1.8.5/whatap/util/cardinality → whatap_python-1.8.14/whatap/trace/mod/application}/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/mod/logging.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/simple_trace_context.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/trace_context.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/trace_context_manager.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/trace/trace_import.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/bit_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/cardinality/hyperloglog.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/cardinality/murmurhash.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/cardinality/registerset.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/compare_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/date_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/debug_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/escape_literal_sql.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/hash_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/hexa32.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/int_set.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/ip_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/keygen.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/linked_list.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/linked_map.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/metering_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/request_double_queue.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/request_queue.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/string_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/throttle_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/util/userid_util.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/__init__.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/blob_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/boolean_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/decimal_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/double_summary.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/double_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/float_array.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/float_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/int_array.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/ip4_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/list_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/long_array.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/long_summary.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/map_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/null_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/number_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/summary_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/text_array.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/text_hash_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/text_value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/value.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/value/value_enum.py +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap/whatap.conf +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap_python.egg-info/dependency_links.txt +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap_python.egg-info/entry_points.txt +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap_python.egg-info/not-zip-safe +0 -0
- {whatap_python-1.8.5 → whatap_python-1.8.14}/whatap_python.egg-info/top_level.txt +0 -0
|
@@ -18,7 +18,7 @@ setup(name=build.name,
|
|
|
18
18
|
author_email='admin@whatap.io',
|
|
19
19
|
license='Whatap License',
|
|
20
20
|
url='https://www.whatap.io',
|
|
21
|
-
packages=find_packages(),
|
|
21
|
+
packages=find_packages(exclude=('sample','sample.*')),
|
|
22
22
|
package_data={
|
|
23
23
|
'whatap': ['LICENSE', '*.rst', '*.conf', '*.json', 'agent/*/*/whatap_python']
|
|
24
24
|
},
|
|
@@ -48,33 +48,41 @@ LOG_FILE_NAME = 'whatap-hook.log'
|
|
|
48
48
|
|
|
49
49
|
isFrappeCommands = "get-frappe-commands" in sys.argv if hasattr(sys, "argv") else False
|
|
50
50
|
|
|
51
|
-
def
|
|
52
|
-
ignore_whatap_stdout = 'false'
|
|
51
|
+
def preview_whatap_conf(option_name:str):
|
|
53
52
|
home = os.environ.get('WHATAP_HOME', '.')
|
|
54
53
|
whatap_config = os.path.join(home, 'whatap.conf')
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
현재 preview_whatap_conf 를 사용중인 옵션
|
|
58
|
+
- ignore_whatap_stdout (False)
|
|
59
|
+
- standalone_enabled (False)
|
|
60
|
+
- counter_thread_enabled (False)
|
|
61
|
+
"""
|
|
62
|
+
value = 'false'
|
|
55
63
|
try:
|
|
56
64
|
with open(whatap_config) as f:
|
|
57
65
|
for raw in f:
|
|
58
66
|
line = raw.strip()
|
|
59
67
|
if not line or line.startswith('#'):
|
|
60
68
|
continue
|
|
61
|
-
if line.startswith(
|
|
69
|
+
if line.startswith(option_name):
|
|
62
70
|
parts = line.split('=', 1)
|
|
63
71
|
if len(parts) == 2:
|
|
64
|
-
|
|
72
|
+
value = parts[1].strip()
|
|
65
73
|
break
|
|
66
|
-
return
|
|
74
|
+
return value
|
|
67
75
|
|
|
68
76
|
except FileNotFoundError:
|
|
69
|
-
return
|
|
77
|
+
return value
|
|
70
78
|
|
|
71
79
|
except Exception as e:
|
|
72
80
|
print(f'WHATAP: config parse error ({e!r})')
|
|
73
|
-
return
|
|
81
|
+
return value
|
|
74
82
|
|
|
75
83
|
|
|
76
84
|
|
|
77
|
-
ignore_whatap_stdout =
|
|
85
|
+
ignore_whatap_stdout = preview_whatap_conf("ignore_whatap_stdout")
|
|
78
86
|
|
|
79
87
|
|
|
80
88
|
|
|
@@ -329,6 +337,14 @@ def hooks(home):
|
|
|
329
337
|
'trace',
|
|
330
338
|
'mod',
|
|
331
339
|
key)}
|
|
340
|
+
|
|
341
|
+
if conf.standalone_enabled:
|
|
342
|
+
if conf.standalone_type == 'multiple-transaction':
|
|
343
|
+
from whatap.trace.mod.standalone.multiple import instrument_standalone_multiple
|
|
344
|
+
instrument_standalone_multiple()
|
|
345
|
+
else:
|
|
346
|
+
from whatap.trace.mod.standalone.single import instrument_standalone_single
|
|
347
|
+
instrument_standalone_single()
|
|
332
348
|
|
|
333
349
|
except Exception as e:
|
|
334
350
|
logging.debug(e, extra={'id': 'PLUGIN ERROR'})
|
|
@@ -354,9 +370,11 @@ def agent():
|
|
|
354
370
|
if write_file(home, home.lower(), whatap_home):
|
|
355
371
|
os.environ['WHATAP_HOME'] = whatap_home
|
|
356
372
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
373
|
+
whatap_code_start = preview_whatap_conf("whatap_code_start")
|
|
374
|
+
if whatap_code_start == 'true':
|
|
375
|
+
t = threading.Thread(target=go)
|
|
376
|
+
t.setDaemon(True)
|
|
377
|
+
t.start()
|
|
360
378
|
config(home)
|
|
361
379
|
|
|
362
380
|
ARCH = {
|
|
@@ -435,9 +453,9 @@ def go(batch=False, opts={}):
|
|
|
435
453
|
|
|
436
454
|
import signal
|
|
437
455
|
|
|
438
|
-
from whatap.trace.mod.
|
|
456
|
+
from whatap.trace.mod.application.wsgi import interceptor, start_interceptor, \
|
|
439
457
|
end_interceptor, trace_handler, interceptor_step_error
|
|
440
|
-
from whatap.trace.mod.
|
|
458
|
+
from whatap.trace.mod.application.fastapi import interceptor_error_log
|
|
441
459
|
from whatap.trace.trace_context import TraceContext, TraceContextManager
|
|
442
460
|
|
|
443
461
|
def register_app(fn):
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Configuration = {
|
|
2
2
|
"dev": False,
|
|
3
|
+
"whatap_code_start": False,
|
|
3
4
|
"ignore_whatap_stdout" : False,
|
|
4
5
|
"net_udp_port": "6600",
|
|
5
6
|
"web_static_content_extensions": "js, htm, html, gif, png, jpg, css, swf, ico",
|
|
7
|
+
|
|
6
8
|
"trace_auto_normalize_enabled": True,
|
|
7
9
|
"trace_user_enabled": True,
|
|
8
10
|
"trace_user_using_ip": True,
|
|
@@ -14,6 +16,8 @@ Configuration = {
|
|
|
14
16
|
"trace_ignore_url_prefix": None,
|
|
15
17
|
"trace_websocket_enabled": False,
|
|
16
18
|
|
|
19
|
+
"trace_llm_log_enabled": False,
|
|
20
|
+
|
|
17
21
|
"debug": False,
|
|
18
22
|
"query_string_enabled": False,
|
|
19
23
|
"query_string_urls": "",
|
|
@@ -50,6 +54,10 @@ Configuration = {
|
|
|
50
54
|
"stat_error_max_count": 1000,
|
|
51
55
|
"stat_useragent_max_count": 500,
|
|
52
56
|
|
|
57
|
+
"standalone_enabled" : False,
|
|
58
|
+
"standalone_type" : "single-transaction",
|
|
59
|
+
"standalone_transaction_patterns" : "",
|
|
60
|
+
|
|
53
61
|
"user_header_ticket_enabled": False,
|
|
54
62
|
"user_header_ticket":"",
|
|
55
63
|
"trace_user_cookie_limit":2048,
|
|
@@ -207,6 +215,9 @@ Configuration = {
|
|
|
207
215
|
"log_unhandled_exception": 'false',
|
|
208
216
|
"threadstack_faulthandler": False,
|
|
209
217
|
"max_send_queue_size": 1000,
|
|
210
|
-
"open_file_descriptor_enabled":False,
|
|
218
|
+
"open_file_descriptor_enabled": False,
|
|
211
219
|
"open_file_descriptor_interval":60,
|
|
220
|
+
"counter_thread_enabled": False,
|
|
221
|
+
"llm_stat_enabled" : False,
|
|
222
|
+
"llm_stat_interval" : 5
|
|
212
223
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from .counter_manager import CounterMgr # CounterMgr 클래스 import
|
|
2
|
+
from whatap import preview_whatap_conf
|
|
3
|
+
|
|
4
|
+
counter_thread_enabled = preview_whatap_conf("counter_thread_enabled")
|
|
5
|
+
|
|
6
|
+
if counter_thread_enabled != 'false':
|
|
7
|
+
mgr = CounterMgr()
|
|
8
|
+
mgr.setDaemon(True)
|
|
9
|
+
mgr.start()
|
|
@@ -3,20 +3,27 @@ import time
|
|
|
3
3
|
import logging
|
|
4
4
|
from threading import Thread
|
|
5
5
|
from .tasks.openfiledescriptor import OpenFileDescriptorTask
|
|
6
|
+
from .tasks.llm_stat import LLMStatTask
|
|
6
7
|
|
|
7
8
|
#현재 디렉토리 아래 tasks 가 있고 그안의 openfiledescriptor.py 파일에 OpenFileDescriptorTask 클래스를 import 하고싶어.
|
|
8
9
|
|
|
9
10
|
class CounterMgr(Thread):
|
|
11
|
+
_instance = None
|
|
10
12
|
def __init__(self):
|
|
11
13
|
super(CounterMgr, self).__init__() # Thread 초기화
|
|
12
14
|
self.tasks = list()
|
|
13
15
|
self.last_executed = {} # 각 task의 마지막 실행 시간을 기록하기 위한 딕셔너리
|
|
14
|
-
|
|
16
|
+
CounterMgr._instance = self
|
|
17
|
+
|
|
15
18
|
def run(self):
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
self.
|
|
19
|
-
|
|
19
|
+
ofd_task = OpenFileDescriptorTask()
|
|
20
|
+
self.tasks.append(ofd_task)
|
|
21
|
+
self.last_executed[ofd_task.name()] = 0 # 각 task의 마지막 실행 시간을 초기화
|
|
22
|
+
|
|
23
|
+
llm_task = LLMStatTask()
|
|
24
|
+
self.tasks.append(llm_task)
|
|
25
|
+
self.last_executed[llm_task.name()] = 0 # 각 task의 마지막 실행 시간을 초기화
|
|
26
|
+
|
|
20
27
|
while True:
|
|
21
28
|
current_time = time.time() # 현재 시간을 초 단위로 가져옴
|
|
22
29
|
time.sleep(1) # 0.1초마다 확인 (부하 줄이기)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import whatap.net.async_sender as async_sender
|
|
2
|
+
import whatap.io as whatapio
|
|
3
|
+
from whatap.pack import tagCountPack
|
|
4
|
+
from whatap.pack.tagCountPack import TagCountPack
|
|
5
|
+
from whatap.util.hash_util import HashUtil
|
|
6
|
+
from whatap import DateUtil
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import time
|
|
10
|
+
from typing import List, Dict, Tuple
|
|
11
|
+
from collections import defaultdict
|
|
12
|
+
|
|
13
|
+
currentpid = os.getpid()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LLMStatTask:
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.llm_stats = {
|
|
19
|
+
'model_calls': defaultdict(int),
|
|
20
|
+
'model_prompt_tokens': defaultdict(int),
|
|
21
|
+
'model_completion_tokens': defaultdict(int)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def name(self):
|
|
25
|
+
return "LLMStatTask"
|
|
26
|
+
|
|
27
|
+
def interval(self):
|
|
28
|
+
from whatap.conf.configure import Configure as conf
|
|
29
|
+
return int(getattr(conf, 'llm_stat_interval', 5))
|
|
30
|
+
|
|
31
|
+
def process(self):
|
|
32
|
+
from whatap.conf.configure import Configure as conf
|
|
33
|
+
enabled = getattr(conf, 'llm_stat_enabled', False)
|
|
34
|
+
if not enabled:
|
|
35
|
+
return
|
|
36
|
+
|
|
37
|
+
stats = self.get_current_stats()
|
|
38
|
+
|
|
39
|
+
if not stats['model_calls']:
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
p = TagCountPack()
|
|
44
|
+
p.time = DateUtil.now() // 1000 * 1000
|
|
45
|
+
p.Category = "llm_stat"
|
|
46
|
+
p.tags.putAuto("pid", currentpid)
|
|
47
|
+
p.tags.putAuto("!rectype", 2)
|
|
48
|
+
|
|
49
|
+
model_id_list = p.fields.newList("@id")
|
|
50
|
+
model_name_list = p.fields.newList("model_name")
|
|
51
|
+
call_count_list = p.fields.newList("call_count")
|
|
52
|
+
prompt_tokens_list = p.fields.newList("prompt_tokens")
|
|
53
|
+
completion_tokens_list = p.fields.newList("completion_tokens")
|
|
54
|
+
total_tokens_list = p.fields.newList("total_tokens")
|
|
55
|
+
|
|
56
|
+
for model_name, count in stats['model_calls'].items():
|
|
57
|
+
prompt_tokens = stats['model_prompt_tokens'][model_name]
|
|
58
|
+
completion_tokens = stats['model_completion_tokens'][model_name]
|
|
59
|
+
total_tokens = prompt_tokens + completion_tokens
|
|
60
|
+
|
|
61
|
+
model_id_list.addLong(HashUtil.hashFromString(model_name))
|
|
62
|
+
model_name_list.addString(model_name)
|
|
63
|
+
call_count_list.addLong(count)
|
|
64
|
+
prompt_tokens_list.addLong(prompt_tokens)
|
|
65
|
+
completion_tokens_list.addLong(completion_tokens)
|
|
66
|
+
total_tokens_list.addLong(total_tokens)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
p.pcode = getattr(conf, 'PCODE', 0)
|
|
70
|
+
bout = whatapio.DataOutputX()
|
|
71
|
+
bout.writePack(p, None)
|
|
72
|
+
packbytes = bout.toByteArray()
|
|
73
|
+
|
|
74
|
+
async_sender.send_relaypack(packbytes)
|
|
75
|
+
self.reset_stats()
|
|
76
|
+
|
|
77
|
+
except Exception as e:
|
|
78
|
+
import traceback
|
|
79
|
+
traceback.print_exc()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_current_stats(self) -> Dict:
|
|
83
|
+
return {
|
|
84
|
+
'model_calls': dict(self.llm_stats['model_calls']),
|
|
85
|
+
'model_prompt_tokens': dict(self.llm_stats['model_prompt_tokens']),
|
|
86
|
+
'model_completion_tokens': dict(self.llm_stats['model_completion_tokens'])
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
def prepare_model_data(self, model_calls: Dict[str, int]) -> Tuple[List[str], List[int]]:
|
|
90
|
+
if not model_calls:
|
|
91
|
+
return [], []
|
|
92
|
+
|
|
93
|
+
models = list(model_calls.keys())
|
|
94
|
+
call_count = [model_calls[model] for model in models]
|
|
95
|
+
|
|
96
|
+
return models, call_count
|
|
97
|
+
|
|
98
|
+
def update_stats(self, prompt_tokens: int, completion_tokens: int,
|
|
99
|
+
model_name: str):
|
|
100
|
+
self.llm_stats['model_calls'][model_name] += 1
|
|
101
|
+
self.llm_stats['model_prompt_tokens'][model_name] += prompt_tokens
|
|
102
|
+
self.llm_stats['model_completion_tokens'][model_name] += completion_tokens
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def reset_stats(self):
|
|
107
|
+
self.llm_stats = {
|
|
108
|
+
'model_calls': defaultdict(int),
|
|
109
|
+
'model_prompt_tokens': defaultdict(int),
|
|
110
|
+
'model_completion_tokens': defaultdict(int)
|
|
111
|
+
}
|
|
@@ -212,9 +212,6 @@ class UdpSession(object):
|
|
|
212
212
|
datas.append(data)
|
|
213
213
|
|
|
214
214
|
cls.send_packet(PacketTypeEnum.ACTIVE_STACK, None, datas)
|
|
215
|
-
stats = TraceContextManager.getActiveStats()
|
|
216
|
-
datas = [','.join([str(x) for x in stats])]
|
|
217
|
-
cls.send_packet(PacketTypeEnum.ACTIVE_STATS, None, datas)
|
|
218
215
|
else:
|
|
219
216
|
# param pack
|
|
220
217
|
# format: "[packetType], [ctx], [datas: xxxx xxxx xxxx]"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import re
|
|
3
|
+
import time
|
|
3
4
|
from functools import wraps
|
|
4
5
|
|
|
5
6
|
import sys, threading
|
|
6
7
|
|
|
7
8
|
from whatap import check_whatap_home, ROOT_DIR, init_config, update_config, \
|
|
8
|
-
batch_agent, AGENT_NAME, go, configPort
|
|
9
|
+
batch_agent, AGENT_NAME, go, configPort, preview_whatap_conf
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def whatap_command(func):
|
|
@@ -73,6 +74,9 @@ def start_agent():
|
|
|
73
74
|
|
|
74
75
|
try:
|
|
75
76
|
go(opts={'whatap.port': str(port)})
|
|
77
|
+
standalone_enabled = preview_whatap_conf("standalone_enabled")
|
|
78
|
+
if standalone_enabled == 'true':
|
|
79
|
+
time.sleep(1)
|
|
76
80
|
except Exception as e:
|
|
77
81
|
print('WHATAP: AGENT ERROR: {}'.format(e))
|
|
78
82
|
print('WHATAP: continue to start user application')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from whatap.trace import get_dict
|
|
2
|
-
from whatap.trace.mod.
|
|
2
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
3
3
|
interceptor_step_error, start_interceptor, end_interceptor
|
|
4
4
|
from whatap.trace.trace_context import TraceContext
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from whatap.trace import get_dict
|
|
2
|
-
from whatap.trace.mod.
|
|
2
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
3
3
|
interceptor_step_error, start_interceptor, end_interceptor
|
|
4
4
|
from whatap.trace.trace_context import TraceContext
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from functools import wraps
|
|
2
2
|
from whatap.trace.trace_context import TraceContext
|
|
3
3
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
4
|
-
from whatap.trace.mod.
|
|
4
|
+
from whatap.trace.mod.application.wsgi import start_interceptor, end_interceptor, interceptor_step_error
|
|
5
5
|
from whatap import logging
|
|
6
6
|
from whatap.conf.configure import Configure as conf
|
|
7
7
|
import time
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from whatap.conf.configure import Configure as conf
|
|
2
2
|
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
3
3
|
import whatap.net.async_sender as async_sender
|
|
4
|
-
from whatap.trace.mod.
|
|
4
|
+
from whatap.trace.mod.application.wsgi import interceptor, trace_handler, \
|
|
5
5
|
interceptor_error, interceptor_step_error
|
|
6
6
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
7
7
|
from whatap.trace.trace_context import TraceContext
|
|
@@ -76,7 +76,7 @@ def instrument_asgi(module):
|
|
|
76
76
|
module.ASGIHandler.__call__ = wrapper(module.ASGIHandler.__call__)
|
|
77
77
|
|
|
78
78
|
try:
|
|
79
|
-
from whatap.trace.mod.
|
|
79
|
+
from whatap.trace.mod.application.django_py3 import \
|
|
80
80
|
instrument_handlers_async, interceptor_async,\
|
|
81
81
|
trace_handler_async, blocking_handler_async,\
|
|
82
82
|
parseHeaders as parseHeadersAsync,\
|
|
@@ -84,7 +84,7 @@ try:
|
|
|
84
84
|
|
|
85
85
|
django_py3_loaded = True
|
|
86
86
|
except Exception as e:
|
|
87
|
-
print("
|
|
87
|
+
print("application.django error:",e)
|
|
88
88
|
django_py3_loaded = False
|
|
89
89
|
|
|
90
90
|
def instrument_handlers_channels(module):
|
|
@@ -4,7 +4,7 @@ from whatap.conf.configure import Configure as conf
|
|
|
4
4
|
from whatap.net import async_sender
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
6
6
|
from whatap.trace.trace_context import TraceContext
|
|
7
|
-
from whatap.trace.mod.
|
|
7
|
+
from whatap.trace.mod.application.wsgi import isIgnore, start_interceptor, end_interceptor
|
|
8
8
|
from whatap.util.hash_util import HashUtil as hash_util
|
|
9
9
|
from whatap.util.userid_util import UseridUtil
|
|
10
10
|
from whatap.util.date_util import DateUtil
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
from whatap.conf.configure import Configure as conf
|
|
3
3
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
4
4
|
from whatap.trace.trace_context import TraceContext
|
|
5
|
-
from whatap.trace.mod.
|
|
5
|
+
from whatap.trace.mod.application.wsgi import \
|
|
6
6
|
interceptor_error,isIgnore, start_interceptor, end_interceptor
|
|
7
7
|
from whatap.util.hash_util import HashUtil as hash_util
|
|
8
8
|
from whatap.util.userid_util import UseridUtil
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from whatap.trace.mod.
|
|
1
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
2
2
|
interceptor_error, start_interceptor, end_interceptor, \
|
|
3
3
|
isIgnore, interceptor_step_error
|
|
4
4
|
from copy import copy
|
|
@@ -443,6 +443,7 @@ def instrument_applications(module):
|
|
|
443
443
|
async def trace(instance, scope, receive, send):
|
|
444
444
|
if scope["type"] != "http":
|
|
445
445
|
await fn(instance, scope, receive, send)
|
|
446
|
+
return
|
|
446
447
|
TraceContext()
|
|
447
448
|
try:
|
|
448
449
|
await fn(instance, scope, receive, send)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from whatap.trace import get_dict
|
|
2
|
-
from whatap.trace.mod.
|
|
2
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
3
3
|
interceptor_step_error, start_interceptor, end_interceptor
|
|
4
4
|
from whatap.trace.trace_context import TraceContext
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from whatap.trace import get_dict
|
|
2
|
-
from whatap.trace.mod.
|
|
2
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
3
3
|
interceptor_step_error, start_interceptor, end_interceptor
|
|
4
4
|
from whatap.trace.trace_context import TraceContext
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import traceback
|
|
2
|
-
from whatap.trace.mod.
|
|
2
|
+
from whatap.trace.mod.application.wsgi import interceptor, trace_handler, interceptor_error
|
|
3
3
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
4
4
|
|
|
5
5
|
|
|
@@ -4,7 +4,7 @@ from whatap.trace.trace_context_manager import TraceContextManager
|
|
|
4
4
|
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
5
5
|
from whatap.util.date_util import DateUtil
|
|
6
6
|
from whatap.util.userid_util import UseridUtil as userid_util
|
|
7
|
-
from whatap.trace.mod.
|
|
7
|
+
from whatap.trace.mod.application.wsgi import interceptor_step_error, \
|
|
8
8
|
start_interceptor,end_interceptor
|
|
9
9
|
from whatap.conf.configure import Configure as conf
|
|
10
10
|
from typing import Any
|
|
@@ -6,7 +6,7 @@ from whatap.trace.trace_context import TraceContext
|
|
|
6
6
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
7
7
|
from whatap.util.date_util import DateUtil
|
|
8
8
|
from whatap.conf.configure import Configure as conf
|
|
9
|
-
from whatap.trace.mod.
|
|
9
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
10
10
|
start_interceptor, end_interceptor, interceptor_error, isIgnore
|
|
11
11
|
|
|
12
12
|
|