Skip to content

Commit e456321

Browse files
authored
Merge pull request #4 from SelfLender/psycopg2-wrapper-context-interception
Add context interception to psycopg2 wrapper
2 parents 298b2f0 + 49eafe7 commit e456321

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

autodynatrace/wrappers/psycopg2/wrapper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def __init__(self, wrapped, dynatrace_db_info):
1818
super(DynatraceCursor, self).__init__(wrapped)
1919
self._self_dynatrace_db_info = dynatrace_db_info
2020

21+
# The `with` context is directly forwarded by the ObjectProxy and we need to intercept it
22+
def __enter__(self):
23+
return self
24+
2125
def execute(self, query, vars=None):
2226
if hasattr(self, "_self_dynatrace_db_info") and self._self_dynatrace_db_info is not None:
2327
with sdk.trace_sql_database_request(self._self_dynatrace_db_info, "{}".format(query)) as tracer:

0 commit comments

Comments
 (0)