Skip to content

Commit b1ccc93

Browse files
committed
Simplify psycopg handling
1 parent 65a12c2 commit b1ccc93

File tree

1 file changed

+5
-6
lines changed
  • instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi

1 file changed

+5
-6
lines changed

instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,10 @@ def calculate_commenter_data(self) -> dict[str, Any]:
352352
if self.database_system == "postgresql":
353353
libpq_version = None
354354
# psycopg
355-
if hasattr(self.connect_module, "pq"):
356-
try:
357-
libpq_version = self.connect_module.pq.version()
358-
except Exception: # pylint: disable=broad-exception-caught
359-
pass
355+
try:
356+
libpq_version = self.connect_module.pq.version()
357+
except AttributeError:
358+
pass
360359

361360
# psycopg2
362361
if libpq_version is None:
@@ -365,7 +364,7 @@ def calculate_commenter_data(self) -> dict[str, Any]:
365364
self.connect_module, "__libpq_version__", None
366365
)
367366

368-
# psycopg also instrument modules that are not the root one, in that case you
367+
# we instrument psycopg modules that are not the root one, in that case you
369368
# won't get the libpq_version
370369
if libpq_version is not None:
371370
commenter_data.update({"libpq_version": libpq_version})

0 commit comments

Comments
 (0)