Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Oct 9, 2024
1 parent cec3a86 commit 47cdaa9
Showing 1 changed file with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
)
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
from opentelemetry.util._importlib_metadata import version
from opentelemetry.util._importlib_metadata import version as util_version

_DB_DRIVER_ALIASES = {
"MySQLdb": "mysqlclient",
Expand Down Expand Up @@ -432,12 +432,18 @@ def traced_execution(
if args and self._commenter_enabled:
try:
args_list = list(args)
db_driver = self._db_api_integration.connect_module.__name__
db_driver = (
self._db_api_integration.connect_module.__name__
)
db_version = ""
if db_driver in _DB_DRIVER_ALIASES.keys():
db_version = version(_DB_DRIVER_ALIASES[db_driver])
if db_driver in _DB_DRIVER_ALIASES:
db_version = util_version(
_DB_DRIVER_ALIASES[db_driver]
)
else:
db_version = self._db_api_integration.connect_module.__version__
db_version = (
self._db_api_integration.connect_module.__version__
)

commenter_data = {
"db_driver": f"{db_driver}:{db_version.split(' ')[0]}",
Expand All @@ -446,9 +452,14 @@ def traced_execution(
"driver_paramstyle": self._connect_module.paramstyle,
}

if self._db_api_integration.database_system == "postgresql":
if (
self._db_api_integration.database_system
== "postgresql"
):
if hasattr(self._connect_module, "__libpq_version__"):
libpq_version = self._connect_module.__libpq_version__
libpq_version = (
self._connect_module.__libpq_version__
)
else:
libpq_version = (
self._connect_module.pq.__build_version__
Expand All @@ -458,21 +469,23 @@ def traced_execution(
"libpq_version": libpq_version,
}
)
elif self._db_api_integration.database_system == "mysql":
elif self._db_api_integration.database_system == "mysql":
mysqlc_version = ""
if db_driver == "mysql.connector":
mysqlc_version = cursor._cnx._cmysql.get_client_info()
mysqlc_version = (
cursor._cnx._cmysql.get_client_info()
)
if db_driver == "MySQLdb":
mysqlc_version = self._db_api_integration.connect_module._mysql.get_client_info()
mysqlc_version = (
self._db_api_integration.connect_module._mysql.get_client_info()
)

commenter_data.update(
{
"mysql_client_version": mysqlc_version,
}
)

_logger.debug("Using commenter_data: %s", commenter_data)

if self._commenter_options.get(
"opentelemetry_values", True
):
Expand Down

0 comments on commit 47cdaa9

Please sign in to comment.