From 2175f7a6bcb8d754198ce9dd180a1c35d17300b0 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 17 Nov 2021 18:13:26 -0500 Subject: [PATCH 1/8] refactor --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0a6a715..e0e8490 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,8 @@ python { tasks { register("buildDist") { - commandLine("sh", "-c", "python setup.py sdist") + executable = "python" + args("setup.py", "sdist") } register("updateDockerFiles") { From 8c70e8c530a0a25db40f6003601ed2f8e8ea898d Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Sun, 21 Nov 2021 20:17:53 -0500 Subject: [PATCH 2/8] just use end path --- sourceplusplus/control/ContextReceiver.py | 2 ++ sourceplusplus/control/LiveInstrumentRemote.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sourceplusplus/control/ContextReceiver.py b/sourceplusplus/control/ContextReceiver.py index 78ea715..4bb2e5b 100644 --- a/sourceplusplus/control/ContextReceiver.py +++ b/sourceplusplus/control/ContextReceiver.py @@ -90,6 +90,8 @@ def apply_log(live_log_id, globals, locals): def apply_breakpoint(live_breakpoint_id, globals, locals): + del locals["ContextReceiver"] + live_breakpoint: LiveBreakpoint = LiveInstrumentRemote.instruments[live_breakpoint_id][1] if live_breakpoint.throttle.is_rate_limited(): return diff --git a/sourceplusplus/control/LiveInstrumentRemote.py b/sourceplusplus/control/LiveInstrumentRemote.py index 5d3d740..0003d8c 100644 --- a/sourceplusplus/control/LiveInstrumentRemote.py +++ b/sourceplusplus/control/LiveInstrumentRemote.py @@ -34,7 +34,7 @@ def add_live_instrument(self, context: LiveInstrumentContext, instrument_type: L else: live_instrument = LiveMeter.from_json(i) bp = LiveInstrumentRemote.dbg.breakpoint( - file=live_instrument.location.source, + file=live_instrument.location.source[live_instrument.location.source.rfind("/") + 1:], line=live_instrument.location.line ) LiveInstrumentRemote.instruments[live_instrument.id] = [bp, live_instrument] From b279dfe964e2face2c57291869839bf89e7295f7 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 22 Nov 2021 13:03:57 -0500 Subject: [PATCH 3/8] add global variables --- sourceplusplus/control/ContextReceiver.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sourceplusplus/control/ContextReceiver.py b/sourceplusplus/control/ContextReceiver.py index 4bb2e5b..bbfe9da 100644 --- a/sourceplusplus/control/ContextReceiver.py +++ b/sourceplusplus/control/ContextReceiver.py @@ -2,6 +2,7 @@ import threading import time import traceback + from skywalking import config, agent from skywalking.protocol.common.Common_pb2 import KeyStringValuePair from skywalking.protocol.logging.Logging_pb2 import LogData, LogDataBody, TextLog, TraceContext, LogTags @@ -102,12 +103,20 @@ def apply_breakpoint(live_breakpoint_id, globals, locals): context: SpanContext = get_context() with context.new_local_span(op=operation) as span: - for key in locals: - var = try_find(key, globals, locals) + for key, value in globals.items(): + tag = StringTag(json.dumps({ + key: str(value), # todo: don't str everything + "@class": str(type(value)), + "@identity": id(value) + })) + tag.key = "spp.global-variable:" + live_breakpoint.id + ":" + key + span.tag(tag) + + for key, value in locals.items(): tag = StringTag(json.dumps({ - key: str(var), # todo: don't str everything - "@class": str(type(var)), - "@identity": id(var) + key: str(value), # todo: don't str everything + "@class": str(type(value)), + "@identity": id(value) })) tag.key = "spp.local-variable:" + live_breakpoint.id + ":" + key span.tag(tag) From 3cceed2653ec7583be5a0c6f2c0f1cfcd6760910 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 22 Nov 2021 13:24:32 -0500 Subject: [PATCH 4/8] python3 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index e0e8490..1adac2b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ python { tasks { register("buildDist") { - executable = "python" + executable = "python3" args("setup.py", "sdist") } From fbdf44eab329b23fec13ff55246c0410ddceb129 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 22 Nov 2021 16:13:22 -0500 Subject: [PATCH 5/8] dont need --- sourceplusplus/control/ContextReceiver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sourceplusplus/control/ContextReceiver.py b/sourceplusplus/control/ContextReceiver.py index bbfe9da..77c4830 100644 --- a/sourceplusplus/control/ContextReceiver.py +++ b/sourceplusplus/control/ContextReceiver.py @@ -91,6 +91,7 @@ def apply_log(live_log_id, globals, locals): def apply_breakpoint(live_breakpoint_id, globals, locals): + del globals["SourcePlusPlus"] del locals["ContextReceiver"] live_breakpoint: LiveBreakpoint = LiveInstrumentRemote.instruments[live_breakpoint_id][1] From bfea5d620aa3bfc33c68c7859d5bfebf48fcbb06 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 22 Nov 2021 16:20:54 -0500 Subject: [PATCH 6/8] avoid key error --- sourceplusplus/control/ContextReceiver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sourceplusplus/control/ContextReceiver.py b/sourceplusplus/control/ContextReceiver.py index 77c4830..b020ea6 100644 --- a/sourceplusplus/control/ContextReceiver.py +++ b/sourceplusplus/control/ContextReceiver.py @@ -91,8 +91,8 @@ def apply_log(live_log_id, globals, locals): def apply_breakpoint(live_breakpoint_id, globals, locals): - del globals["SourcePlusPlus"] - del locals["ContextReceiver"] + globals.pop("SourcePlusPlus", None) + locals.pop("ContextReceiver", None) live_breakpoint: LiveBreakpoint = LiveInstrumentRemote.instruments[live_breakpoint_id][1] if live_breakpoint.throttle.is_rate_limited(): From 55867fdcfd280f74615bb28cb6c11610db069731 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 22 Nov 2021 16:23:39 -0500 Subject: [PATCH 7/8] bump --- setup.py | 2 +- sourceplusplus/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a8629f4..f9d5498 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup(name='sourceplusplus', - version='0.1.3', + version='0.1.4', description='Source++ Python Probe', url='https://github.com/sourceplusplus/probe-python', author='Source++', diff --git a/sourceplusplus/__init__.py b/sourceplusplus/__init__.py index 8a3c2fa..d441b7c 100644 --- a/sourceplusplus/__init__.py +++ b/sourceplusplus/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.1.3' +__version__ = '0.1.4' __name__ = 'Source++' agent_name = 'Source++ Python Probe' From 4172136c81978a66f0d608e478679dc440981165 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 22 Nov 2021 16:24:24 -0500 Subject: [PATCH 8/8] bump --- e2e/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/Dockerfile b/e2e/Dockerfile index eafe6fa..cd8efce 100644 --- a/e2e/Dockerfile +++ b/e2e/Dockerfile @@ -6,9 +6,9 @@ RUN pip install Flask RUN pip install PyYAML RUN pip install vertx-eventbus-client -COPY sourceplusplus-0.1.2.tar.gz . +COPY sourceplusplus-0.1.4.tar.gz . -RUN pip install sourceplusplus-0.1.2.tar.gz +RUN pip install sourceplusplus-0.1.4.tar.gz COPY E2ETest.py .