Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
bartv committed Jun 24, 2024
1 parent 75ec544 commit 2ada10f
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ def _instrument(self, **kwargs):

def _uninstrument(self, **__):
for cls, methods in [
(asyncpg.connection.Connection, ("execute", "executemany", "fetch", "fetchval", "fetchrow")),
(asyncpg.cursor.Cursor, ("forward", "fetch", "fetchrow")),
(asyncpg.cursor.CursorIterator, ("__anext__", ))
(
asyncpg.connection.Connection,
("execute", "executemany", "fetch", "fetchval", "fetchrow"),
),
(asyncpg.cursor.Cursor, ("forward", "fetch", "fetchrow")),
(asyncpg.cursor.CursorIterator, ("__anext__",)),
]:
for method_name in methods:
unwrap(cls, method_name)
Expand Down Expand Up @@ -181,11 +184,14 @@ async def _do_execute(self, func, instance, args, kwargs):
return result

async def _do_cursor_execute(self, func, instance, args, kwargs):
""" Wrap curser based functions. For every call this will generate a new span.
"""
"""Wrap curser based functions. For every call this will generate a new span."""
exception = None
params = getattr(instance._connection, "_params", {})
name = instance._query if instance._query else params.get("database", "postgresql")
name = (
instance._query
if instance._query
else params.get("database", "postgresql")
)

try:
# Strip leading comments so we get the operation name.
Expand All @@ -195,7 +201,8 @@ async def _do_cursor_execute(self, func, instance, args, kwargs):

stop = False
with self._tracer.start_as_current_span(
f"CURSOR: {name}", kind=SpanKind.CLIENT,
f"CURSOR: {name}",
kind=SpanKind.CLIENT,
) as span:
if span.is_recording():
span_attributes = _hydrate_span_from_args(
Expand Down

0 comments on commit 2ada10f

Please sign in to comment.