From e9fba7b064902ceedee0dd5578cb47030665a6aa Mon Sep 17 00:00:00 2001
From: timofey <tim@ongoteam.yaconnect.com>
Date: Fri, 4 Nov 2022 09:38:59 +0000
Subject: [PATCH] enter_conditional

---
 rainbowadn/instrument/instrumentation.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/rainbowadn/instrument/instrumentation.py b/rainbowadn/instrument/instrumentation.py
index 18147c5..bb8be28 100644
--- a/rainbowadn/instrument/instrumentation.py
+++ b/rainbowadn/instrument/instrumentation.py
@@ -58,3 +58,10 @@ class Instrumentation(Generic[IType]):
     def enter(self: IType, stack: ExitStack) -> IType:
         assert isinstance(self, Instrumentation)
         return stack.enter_context(self)
+    
+    def enter_conditional(self: IType, stack: ExitStack) -> IType | None:
+        assert isinstance(self, Instrumentation)
+        if hasattr(self.target, self.methodname):
+            return self.enter(stack)
+        else:
+            return None