Review change
Don't make function call unnecessarily when span is not recording
This commit is contained in:
parent
0b8deb46d8
commit
dc98748c50
|
|
@ -118,19 +118,22 @@ class AsyncPGInstrumentor(BaseInstrumentor):
|
||||||
tracer = getattr(asyncpg, _APPLIED)
|
tracer = getattr(asyncpg, _APPLIED)
|
||||||
|
|
||||||
exception = None
|
exception = None
|
||||||
span_attributes = _hydrate_span_from_args(
|
params = getattr(instance, "_params", None)
|
||||||
instance, args[0], args[1:] if self.capture_parameters else None
|
|
||||||
)
|
|
||||||
name = ""
|
name = ""
|
||||||
if args[0]:
|
if args[0]:
|
||||||
name = args[0]
|
name = args[0]
|
||||||
elif span_attributes.get("db.name"):
|
elif params and params.get("database"):
|
||||||
name = span_attributes["db.name"]
|
name = params.get("database")
|
||||||
else:
|
else:
|
||||||
name = "postgresql" # Does it ever happen?
|
name = "postgresql" # Does it ever happen?
|
||||||
|
|
||||||
with tracer.start_as_current_span(name, kind=SpanKind.CLIENT) as span:
|
with tracer.start_as_current_span(name, kind=SpanKind.CLIENT) as span:
|
||||||
if span.is_recording():
|
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():
|
for attribute, value in span_attributes.items():
|
||||||
span.set_attribute(attribute, value)
|
span.set_attribute(attribute, value)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue