From 1bca88252f767fc1237613c8e5e2c1116479226b Mon Sep 17 00:00:00 2001 From: Robert Brewer Date: Wed, 10 Jul 2019 18:01:16 -0700 Subject: [PATCH] Oops. --- README.md | 4 ++-- src/diagnose/managers.py | 4 ++-- src/diagnose/probes.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd2b79e..3da3aa8 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Individual probes can be created directly by calling `attach_to(target)`: >>> myclass().add13(arg=5) 18 >>> p = diagnose.probes.attach_to("path.to.module.myclass.add13") ->>> p.instruments["foo"] = diagnose.LogInstrument("foo", "arg", internal=False) +>>> p.instruments["foo"] = diagnose.LogInstrument("foo", "arg") >>> p.start() >>> myclass().add13(arg=5) Probe (foo) = 5 @@ -56,7 +56,7 @@ Later, you can define instruments: "type": "log", "name": "myapp.method", "value": "result", - "internal": False, + "event": "return", "custom": {}, }, "lifespan": 10, diff --git a/src/diagnose/managers.py b/src/diagnose/managers.py index 9f28143..c192982 100644 --- a/src/diagnose/managers.py +++ b/src/diagnose/managers.py @@ -37,7 +37,7 @@ class InstrumentManager(object): * lastmodified: the datetime when the spec was last changed * lifespan: an int; the number of minutes from lastmodified before the instrument should expire. - * instrument: a dict of Instrument params (type, name, value, internal, custom). + * instrument: a dict of Instrument params (type, name, value, event, custom). The "expires" param is calculated from lastmodified + lifespan. * applied: a dict of {process_id: info} pairs, where "info" is a dict with: * lm: the "lastmodified" datetime of the instrument when @@ -96,7 +96,7 @@ def _apply(self): ) modified = True else: - for key in ("name", "value", "internal", "custom"): + for key in ("name", "value", "event", "custom"): if getattr(I, key) != doc["instrument"][key]: setattr(I, key, doc["instrument"][key]) modified = True diff --git a/src/diagnose/probes.py b/src/diagnose/probes.py index 08b8cc7..9a799dc 100644 --- a/src/diagnose/probes.py +++ b/src/diagnose/probes.py @@ -201,8 +201,6 @@ def probe_wrapper(*args, **kwargs): "kwargs": kwargs, "frame": sys._getframe(), } - if hotspots.enabled: - _locals["hotspots"] = hotspots # Add positional args to locals by name. for i, argname in enumerate(varnames[: len(args)]): _locals[argname] = args[i] @@ -223,6 +221,7 @@ def probe_wrapper(*args, **kwargs): if hotspots.enabled: hotspots.finish() + _locals["hotspots"] = hotspots if instruments_by_event["return"]: end = time.time()