Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,16 @@ async def _do_execute(self, func, instance, args, kwargs):
except IndexError:
name = ""

# Hydrate attributes before span creation to enable filtering
span_attributes = _hydrate_span_from_args(
instance,
args[0],
args[1:] if self.capture_parameters else None,
)

with self._tracer.start_as_current_span(
name, kind=SpanKind.CLIENT
name, kind=SpanKind.CLIENT, attributes=span_attributes
) as span:
if span.is_recording():
span_attributes = _hydrate_span_from_args(
instance,
args[0],
args[1:] if self.capture_parameters else None,
)
for attribute, value in span_attributes.items():
span.set_attribute(attribute, value)

try:
result = await func(*args, **kwargs)
except Exception as exc: # pylint: disable=W0703
Expand Down Expand Up @@ -217,20 +215,19 @@ async def _do_cursor_execute(self, func, instance, args, kwargs):
except IndexError:
name = ""

# Hydrate attributes before span creation to enable filtering
span_attributes = _hydrate_span_from_args(
instance._connection,
instance._query,
instance._args if self.capture_parameters else None,
)

stop = False
with self._tracer.start_as_current_span(
f"CURSOR: {name}",
kind=SpanKind.CLIENT,
attributes=span_attributes,
) as span:
if span.is_recording():
span_attributes = _hydrate_span_from_args(
instance._connection,
instance._query,
instance._args if self.capture_parameters else None,
)
for attribute, value in span_attributes.items():
span.set_attribute(attribute, value)

try:
result = await func(*args, **kwargs)
except StopAsyncIteration:
Expand Down