whatap-python 1.8.6__tar.gz → 1.8.8__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.8.6 → whatap_python-1.8.8}/PKG-INFO +1 -1
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/__init__.py +16 -12
- whatap_python-1.8.8/whatap/build.py +4 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/conf/configuration.py +4 -0
- whatap_python-1.8.8/whatap/counter/__init__.py +9 -0
- whatap_python-1.8.6/whatap/trace/mod/amqp_kombu.py → whatap_python-1.8.8/whatap/trace/mod/amqp/kombu.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/amqp_pika.py → whatap_python-1.8.8/whatap/trace/mod/amqp/pika.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_bottle.py → whatap_python-1.8.8/whatap/trace/mod/application/bottle.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_celery.py → whatap_python-1.8.8/whatap/trace/mod/application/celery.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_cherrypy.py → whatap_python-1.8.8/whatap/trace/mod/application/cherrypy.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_django.py → whatap_python-1.8.8/whatap/trace/mod/application/django.py +3 -3
- whatap_python-1.8.6/whatap/trace/mod/application_django_asgi.py → whatap_python-1.8.8/whatap/trace/mod/application/django_asgi.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_django_py3.py → whatap_python-1.8.8/whatap/trace/mod/application/django_py3.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_fastapi.py → whatap_python-1.8.8/whatap/trace/mod/application/fastapi.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_flask.py → whatap_python-1.8.8/whatap/trace/mod/application/flask.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_frappe.py → whatap_python-1.8.8/whatap/trace/mod/application/frappe.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_graphql.py → whatap_python-1.8.8/whatap/trace/mod/application/graphql.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_nameko.py → whatap_python-1.8.8/whatap/trace/mod/application/nameko.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_odoo.py → whatap_python-1.8.8/whatap/trace/mod/application/odoo.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_starlette.py → whatap_python-1.8.8/whatap/trace/mod/application/starlette.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/application_tornado.py → whatap_python-1.8.8/whatap/trace/mod/application/tornado.py +1 -1
- whatap_python-1.8.8/whatap/trace/mod/database/__init__.py +0 -0
- whatap_python-1.8.6/whatap/trace/mod/database_cxoracle.py → whatap_python-1.8.8/whatap/trace/mod/database/cxoracle.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/database_mongo.py → whatap_python-1.8.8/whatap/trace/mod/database/mongo.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/database_mysql.py → whatap_python-1.8.8/whatap/trace/mod/database/mysql.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/database_neo4j.py → whatap_python-1.8.8/whatap/trace/mod/database/neo4j.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/database_postgresql.py → whatap_python-1.8.8/whatap/trace/mod/database/postgresql.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/database_redis.py → whatap_python-1.8.8/whatap/trace/mod/database/redis.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/database_toolkit.py → whatap_python-1.8.8/whatap/trace/mod/database/toolkit.py +1 -1
- whatap_python-1.8.8/whatap/trace/mod/email/__init__.py +0 -0
- whatap_python-1.8.6/whatap/trace/mod/email_smtp.py → whatap_python-1.8.8/whatap/trace/mod/email/smtp.py +1 -1
- whatap_python-1.8.8/whatap/trace/mod/httpc/__init__.py +0 -0
- whatap_python-1.8.6/whatap/trace/mod/httpc_django.py → whatap_python-1.8.8/whatap/trace/mod/httpc/django.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/httpc_httplib.py → whatap_python-1.8.8/whatap/trace/mod/httpc/httplib.py +1 -1
- whatap_python-1.8.8/whatap/trace/mod/httpc/httpx.py +24 -0
- whatap_python-1.8.6/whatap/trace/mod/httpc_requests.py → whatap_python-1.8.8/whatap/trace/mod/httpc/requests.py +1 -1
- whatap_python-1.8.6/whatap/trace/mod/httpc_urllib3.py → whatap_python-1.8.8/whatap/trace/mod/httpc/urllib3.py +1 -1
- whatap_python-1.8.8/whatap/trace/mod/llm/__init__.py +0 -0
- whatap_python-1.8.8/whatap/trace/mod/llm/openai.py +199 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/mod/plugin.py +1 -1
- whatap_python-1.8.8/whatap/trace/mod/standalone/__init__.py +0 -0
- whatap_python-1.8.6/whatap/trace/mod/standalone_multiple.py → whatap_python-1.8.8/whatap/trace/mod/standalone/multiple.py +1 -1
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/trace_module_definition.py +33 -27
- whatap_python-1.8.8/whatap/util/__init__.py +0 -0
- whatap_python-1.8.8/whatap/util/cardinality/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap_python.egg-info/PKG-INFO +1 -1
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap_python.egg-info/SOURCES.txt +40 -31
- whatap_python-1.8.6/whatap/build.py +0 -4
- whatap_python-1.8.6/whatap/counter/__init__.py +0 -6
- {whatap_python-1.8.6 → whatap_python-1.8.8}/README.md +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/setup.cfg +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/setup.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/LICENSE +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/README.rst +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/__main__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/agent/darwin/amd64/whatap_python +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/agent/darwin/arm64/whatap_python +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/agent/linux/amd64/whatap_python +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/agent/linux/arm64/whatap_python +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/bootstrap/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/bootstrap/sitecustomize.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/conf/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/conf/configure.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/conf/license.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/control/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/counter/counter_manager.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/counter/tasks/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/counter/tasks/openfiledescriptor.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/io/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/io/data_inputx.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/io/data_outputx.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/async_sender.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/packet_enum.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/packet_type_enum.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/param_def.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/stackhelper.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/udp_session.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/net/udp_thread.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/pack/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/pack/logSinkPack.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/pack/pack.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/pack/pack_enum.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/pack/tagCountPack.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/scripts/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/mod/__init__.py +0 -0
- {whatap_python-1.8.6/whatap/util → whatap_python-1.8.8/whatap/trace/mod/amqp}/__init__.py +0 -0
- {whatap_python-1.8.6/whatap/util/cardinality → whatap_python-1.8.8/whatap/trace/mod/application}/__init__.py +0 -0
- /whatap_python-1.8.6/whatap/trace/mod/application_wsgi.py → /whatap_python-1.8.8/whatap/trace/mod/application/wsgi.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/mod/logging.py +0 -0
- /whatap_python-1.8.6/whatap/trace/mod/standalone_single.py → /whatap_python-1.8.8/whatap/trace/mod/standalone/single.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/simple_trace_context.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/trace_context.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/trace_context_manager.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/trace/trace_import.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/bit_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/cardinality/hyperloglog.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/cardinality/murmurhash.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/cardinality/registerset.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/compare_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/date_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/debug_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/escape_literal_sql.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/hash_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/hexa32.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/int_set.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/ip_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/keygen.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/linked_list.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/linked_map.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/metering_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/request_double_queue.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/request_queue.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/string_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/throttle_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/util/userid_util.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/__init__.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/blob_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/boolean_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/decimal_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/double_summary.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/double_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/float_array.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/float_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/int_array.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/ip4_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/list_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/long_array.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/long_summary.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/map_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/null_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/number_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/summary_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/text_array.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/text_hash_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/text_value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/value.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/value/value_enum.py +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap/whatap.conf +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap_python.egg-info/dependency_links.txt +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap_python.egg-info/entry_points.txt +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap_python.egg-info/not-zip-safe +0 -0
- {whatap_python-1.8.6 → whatap_python-1.8.8}/whatap_python.egg-info/top_level.txt +0 -0
|
@@ -52,12 +52,14 @@ def preview_whatap_conf(option_name:str):
|
|
|
52
52
|
home = os.environ.get('WHATAP_HOME', '.')
|
|
53
53
|
whatap_config = os.path.join(home, 'whatap.conf')
|
|
54
54
|
|
|
55
|
-
#기본 default 값 설정
|
|
56
|
-
if option_name == "ignore_whatap_stdout":
|
|
57
|
-
value = 'false'
|
|
58
|
-
elif option_name == "standalone_enabled":
|
|
59
|
-
value = 'false'
|
|
60
55
|
|
|
56
|
+
"""
|
|
57
|
+
현재 preview_whatap_conf 를 사용중인 옵션
|
|
58
|
+
- ignore_whatap_stdout (False)
|
|
59
|
+
- standalone_enabled (False)
|
|
60
|
+
- open_file_descriptor_enabled (False)
|
|
61
|
+
"""
|
|
62
|
+
value = 'false'
|
|
61
63
|
try:
|
|
62
64
|
with open(whatap_config) as f:
|
|
63
65
|
for raw in f:
|
|
@@ -338,10 +340,10 @@ def hooks(home):
|
|
|
338
340
|
|
|
339
341
|
if conf.standalone_enabled:
|
|
340
342
|
if conf.standalone_type == 'multiple-transaction':
|
|
341
|
-
from whatap.trace.mod.
|
|
343
|
+
from whatap.trace.mod.standalone.multiple import instrument_standalone_multiple
|
|
342
344
|
instrument_standalone_multiple()
|
|
343
345
|
else:
|
|
344
|
-
from whatap.trace.mod.
|
|
346
|
+
from whatap.trace.mod.standalone.single import instrument_standalone_single
|
|
345
347
|
instrument_standalone_single()
|
|
346
348
|
|
|
347
349
|
except Exception as e:
|
|
@@ -368,9 +370,11 @@ def agent():
|
|
|
368
370
|
if write_file(home, home.lower(), whatap_home):
|
|
369
371
|
os.environ['WHATAP_HOME'] = whatap_home
|
|
370
372
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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()
|
|
374
378
|
config(home)
|
|
375
379
|
|
|
376
380
|
ARCH = {
|
|
@@ -449,9 +453,9 @@ def go(batch=False, opts={}):
|
|
|
449
453
|
|
|
450
454
|
import signal
|
|
451
455
|
|
|
452
|
-
from whatap.trace.mod.
|
|
456
|
+
from whatap.trace.mod.application.wsgi import interceptor, start_interceptor, \
|
|
453
457
|
end_interceptor, trace_handler, interceptor_step_error
|
|
454
|
-
from whatap.trace.mod.
|
|
458
|
+
from whatap.trace.mod.application.fastapi import interceptor_error_log
|
|
455
459
|
from whatap.trace.trace_context import TraceContext, TraceContextManager
|
|
456
460
|
|
|
457
461
|
def register_app(fn):
|
|
@@ -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": "",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from .counter_manager import CounterMgr # CounterMgr 클래스 import
|
|
2
|
+
from whatap import preview_whatap_conf
|
|
3
|
+
|
|
4
|
+
open_file_descriptor_enabled = preview_whatap_conf("open_file_descriptor_enabled")
|
|
5
|
+
|
|
6
|
+
if open_file_descriptor_enabled != 'false':
|
|
7
|
+
mgr = CounterMgr()
|
|
8
|
+
mgr.setDaemon(True)
|
|
9
|
+
mgr.start()
|
|
@@ -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,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
|
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pymongo.monitoring
|
|
2
2
|
from whatap.trace import get_dict
|
|
3
|
-
from whatap.trace.mod.
|
|
3
|
+
from whatap.trace.mod.application.wsgi import trace_handler, \
|
|
4
4
|
interceptor_step_error
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
6
6
|
import whatap.net.async_sender as async_sender
|
|
@@ -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, interceptor_step_error
|
|
3
3
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
4
4
|
import whatap.net.async_sender as async_sender
|
|
5
5
|
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
2
2
|
import whatap.net.async_sender as async_sender
|
|
3
|
-
from whatap.trace.mod.
|
|
3
|
+
from whatap.trace.mod.application.wsgi import trace_handler, interceptor_db_execute, interceptor_step_error, sendDebugProfile
|
|
4
4
|
from whatap.util.date_util import DateUtil
|
|
5
5
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
6
6
|
import sys
|
|
File without changes
|
|
@@ -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
|
|
4
4
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
5
5
|
import whatap.net.async_sender as async_sender
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from whatap.trace.mod.application.wsgi import transfer, trace_handler, \
|
|
2
|
+
interceptor_httpc_request
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def instrument_httpx(module):
|
|
6
|
+
def wrapper(fn):
|
|
7
|
+
@trace_handler(fn)
|
|
8
|
+
def trace(*args, **kwargs):
|
|
9
|
+
request = args[1]
|
|
10
|
+
request.headers = transfer(request.headers)
|
|
11
|
+
|
|
12
|
+
httpc_url = str(request.url)
|
|
13
|
+
callback = interceptor_httpc_request(fn, httpc_url, *args, **kwargs)
|
|
14
|
+
|
|
15
|
+
return callback
|
|
16
|
+
|
|
17
|
+
return trace
|
|
18
|
+
|
|
19
|
+
if hasattr(module, 'Client') and hasattr(module.Client, 'send'):
|
|
20
|
+
module.Client.send = wrapper(module.Client.send)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if hasattr(module, 'AsyncClient') and hasattr(module.AsyncClient, 'send'):
|
|
24
|
+
module.AsyncClient.send = wrapper(module.AsyncClient.send)
|
|
File without changes
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from openai import OpenAIError
|
|
5
|
+
|
|
6
|
+
from whatap import DateUtil, conf
|
|
7
|
+
from whatap.pack import logSinkPack
|
|
8
|
+
from whatap.trace.trace_context_manager import TraceContextManager
|
|
9
|
+
from whatap.trace.mod.application.wsgi import trace_handler
|
|
10
|
+
|
|
11
|
+
import whatap.io as whatapio
|
|
12
|
+
import whatap.net.async_sender as async_sender
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def __send_llm_pack(metadata):
|
|
16
|
+
try:
|
|
17
|
+
ctx = TraceContextManager.getLocalContext()
|
|
18
|
+
|
|
19
|
+
input_text = metadata.get("input_text", "")
|
|
20
|
+
output_text = metadata.get("output_text", "")
|
|
21
|
+
content = f"[REQUEST]{input_text}\n[RESPONSE]{output_text}"
|
|
22
|
+
|
|
23
|
+
tags = {'@txid': str(ctx.id)} if ctx else {}
|
|
24
|
+
fields = {}
|
|
25
|
+
|
|
26
|
+
# 1. 기본 LLM 팩 데이터 구성
|
|
27
|
+
llm_tags = {
|
|
28
|
+
'ip': metadata.get('ip'),
|
|
29
|
+
'host_name': metadata.get('host_name'),
|
|
30
|
+
'model': metadata.get('model'),
|
|
31
|
+
'stream': str(metadata.get('stream', False)),
|
|
32
|
+
'success': str(metadata.get('success', False))
|
|
33
|
+
}
|
|
34
|
+
tags.update(llm_tags)
|
|
35
|
+
|
|
36
|
+
llm_fields = {
|
|
37
|
+
'prompt_tokens': metadata.get('prompt_tokens'),
|
|
38
|
+
'completion_tokens': metadata.get('completion_tokens'),
|
|
39
|
+
'total_tokens': metadata.get('total_tokens'),
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fields.update(llm_fields)
|
|
43
|
+
|
|
44
|
+
# 2. 에러 데이터 팩인지 확인
|
|
45
|
+
if (metadata.get('error_type') == 'api_error'):
|
|
46
|
+
error_fields = {
|
|
47
|
+
"error": metadata.get('error'),
|
|
48
|
+
"error_type": "api_error",
|
|
49
|
+
}
|
|
50
|
+
fields.update(error_fields)
|
|
51
|
+
|
|
52
|
+
elif (metadata.get('error_type') == 'program_error'):
|
|
53
|
+
error_fields = {
|
|
54
|
+
"error": metadata.get('error'),
|
|
55
|
+
"error_type": "program_error",
|
|
56
|
+
}
|
|
57
|
+
fields.update(error_fields)
|
|
58
|
+
|
|
59
|
+
# 3. value 가 None 이 아닌 것들로 tags,fields 재구성
|
|
60
|
+
tags = {k: v for k, v in tags.items() if v is not None}
|
|
61
|
+
fields = {k: v for k, v in fields.items() if v is not None}
|
|
62
|
+
|
|
63
|
+
p = logSinkPack.getLogSinkPack(
|
|
64
|
+
t=DateUtil.now(),
|
|
65
|
+
category="LLMResponse",
|
|
66
|
+
tags=tags,
|
|
67
|
+
fields=fields,
|
|
68
|
+
line=DateUtil.now(),
|
|
69
|
+
content=content
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
p.pcode = conf.PCODE
|
|
73
|
+
bout = whatapio.DataOutputX()
|
|
74
|
+
bout.writePack(p, None)
|
|
75
|
+
packbytes = bout.toByteArray()
|
|
76
|
+
try:
|
|
77
|
+
async_sender.send_relaypack(packbytes)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
logging.debug(str(e))
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
except Exception as e:
|
|
83
|
+
logging.debug(str(e))
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def __streaming_response_wrapper(response_stream, metadata, prompt_tokens):
|
|
88
|
+
collected_text = ""
|
|
89
|
+
is_first_chunk = True
|
|
90
|
+
#TODO
|
|
91
|
+
"""
|
|
92
|
+
스트리밍 경우인 경우, completion_tokens 의 개수를 가져올 수 없기 때문에 토큰 계산 모듈을 통해, 추출하는 방법밖에 없음.
|
|
93
|
+
현재 관련 로직에 대해서 개발된 바가 없기에 0으로 제공중임.
|
|
94
|
+
"""
|
|
95
|
+
completion_tokens = 0
|
|
96
|
+
try:
|
|
97
|
+
for chunk in response_stream:
|
|
98
|
+
if is_first_chunk:
|
|
99
|
+
is_first_chunk = False
|
|
100
|
+
|
|
101
|
+
delta = chunk.choices[0].delta
|
|
102
|
+
content = getattr(delta, "content", None) or ""
|
|
103
|
+
collected_text += content
|
|
104
|
+
yield chunk
|
|
105
|
+
finally:
|
|
106
|
+
metadata.update({
|
|
107
|
+
"completion_tokens": completion_tokens,
|
|
108
|
+
"total_tokens": prompt_tokens + completion_tokens,
|
|
109
|
+
"output_text": collected_text,
|
|
110
|
+
"success": True,
|
|
111
|
+
})
|
|
112
|
+
__send_llm_pack(metadata)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def intercept_create(fn, *args, **kwargs):
|
|
116
|
+
prompt_messages = kwargs.get("messages", [])
|
|
117
|
+
model_name = kwargs.get("model")
|
|
118
|
+
stream_flag = kwargs.get("stream", False)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
input_text = "".join([msg.get("content", "") or "" for msg in prompt_messages])
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
metadata = {
|
|
125
|
+
"ip": socket.gethostbyname(socket.gethostname()),
|
|
126
|
+
"host_name": socket.gethostname(),
|
|
127
|
+
"model": model_name,
|
|
128
|
+
"input_text": input_text,
|
|
129
|
+
"stream": stream_flag,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
response = fn(*args, **kwargs)
|
|
134
|
+
|
|
135
|
+
usage = getattr(response, "usage", None)
|
|
136
|
+
prompt_tokens = getattr(usage, "prompt_tokens", 0)
|
|
137
|
+
completion_tokens = getattr(usage, "completion_tokens", 0)
|
|
138
|
+
|
|
139
|
+
except OpenAIError as api_err:
|
|
140
|
+
metadata.update({
|
|
141
|
+
"success": False,
|
|
142
|
+
"error": str(api_err),
|
|
143
|
+
"error_type": "api_error"
|
|
144
|
+
})
|
|
145
|
+
__send_llm_pack(metadata)
|
|
146
|
+
raise api_err
|
|
147
|
+
|
|
148
|
+
except Exception as code_err:
|
|
149
|
+
metadata.update({
|
|
150
|
+
"success": False,
|
|
151
|
+
"error": str(code_err),
|
|
152
|
+
"error_type": "program_error"
|
|
153
|
+
})
|
|
154
|
+
__send_llm_pack(metadata)
|
|
155
|
+
raise code_err
|
|
156
|
+
|
|
157
|
+
if stream_flag:
|
|
158
|
+
return __streaming_response_wrapper(response, metadata, prompt_tokens)
|
|
159
|
+
|
|
160
|
+
try:
|
|
161
|
+
response_text = "".join([choice.message.content or "" for choice in response.choices])
|
|
162
|
+
except Exception as e:
|
|
163
|
+
raise e
|
|
164
|
+
|
|
165
|
+
metadata.update({
|
|
166
|
+
"prompt_tokens": prompt_tokens,
|
|
167
|
+
"completion_tokens": completion_tokens,
|
|
168
|
+
"total_tokens": prompt_tokens + completion_tokens,
|
|
169
|
+
"output_text": response_text,
|
|
170
|
+
"success": True,
|
|
171
|
+
})
|
|
172
|
+
__send_llm_pack(metadata)
|
|
173
|
+
|
|
174
|
+
if not hasattr(response, "choices"):
|
|
175
|
+
logging.debug("The returned object doesn't have attribute which is 'choices'")
|
|
176
|
+
|
|
177
|
+
return response
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def instrument_openai(module):
|
|
181
|
+
|
|
182
|
+
if not (conf.trace_llm_log_enabled):
|
|
183
|
+
return
|
|
184
|
+
|
|
185
|
+
def create_wrapper(fn):
|
|
186
|
+
@trace_handler(fn)
|
|
187
|
+
def trace(*args, **kwargs):
|
|
188
|
+
return intercept_create(fn, *args, **kwargs)
|
|
189
|
+
|
|
190
|
+
return trace
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
if (hasattr(module, 'resources') and
|
|
194
|
+
hasattr(module.resources, 'chat') and
|
|
195
|
+
hasattr(module.resources.chat, 'completions') and
|
|
196
|
+
hasattr(module.resources.chat.completions, 'Completions') and
|
|
197
|
+
hasattr(module.resources.chat.completions.Completions, 'create')):
|
|
198
|
+
original_create = module.resources.chat.completions.Completions.create
|
|
199
|
+
module.resources.chat.completions.Completions.create = create_wrapper(original_create)
|
|
@@ -2,7 +2,7 @@ import inspect
|
|
|
2
2
|
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
3
3
|
import whatap.net.async_sender as async_sender
|
|
4
4
|
from whatap.trace import get_dict
|
|
5
|
-
from whatap.trace.mod.
|
|
5
|
+
from whatap.trace.mod.application.wsgi import trace_handler
|
|
6
6
|
from whatap.util.date_util import DateUtil
|
|
7
7
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
8
8
|
|
|
File without changes
|
|
@@ -12,7 +12,7 @@ from whatap.util.date_util import DateUtil
|
|
|
12
12
|
from whatap.trace.trace_context import TraceContext
|
|
13
13
|
from whatap.trace.trace_context_manager import TraceContextManager
|
|
14
14
|
from whatap.net.packet_type_enum import PacketTypeEnum
|
|
15
|
-
from whatap.trace.mod.
|
|
15
|
+
from whatap.trace.mod.application.wsgi import trace_handler
|
|
16
16
|
from whatap import logging
|
|
17
17
|
|
|
18
18
|
def trace_handler(fn, start=False, preload=None):
|