Skip to content

Commit

Permalink
Add _DB_DRIVER_ALIASES
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Oct 9, 2024
1 parent 224a771 commit 3c43604
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
)
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
from opentelemetry.util._importlib_metadata import version

_DB_DRIVER_ALIASES = {
"MySQLdb": "mysqlclient",
}

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -428,9 +433,14 @@ def traced_execution(
try:
args_list = list(args)
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])
else:
db_version = self._db_api_integration.connect_module.__version__

commenter_data = {
# TODO MySQLdb attribute
"db_driver": f"{db_driver}:{self._connect_module.__version__.split(' ')[0]}",
"db_driver": f"{db_driver}:{db_version.split(' ')[0]}",
"dbapi_threadsafety": self._connect_module.threadsafety,
"dbapi_level": self._connect_module.apilevel,
"driver_paramstyle": self._connect_module.paramstyle,
Expand Down

0 comments on commit 3c43604

Please sign in to comment.