Skip to content

Commit

Permalink
support opentelemetry-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Jan 10, 2025
1 parent 8103651 commit a4c2a49
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/MySQLdb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,19 @@ class object, used to create cursors (keyword only)
if type(k) is not int # noqa: E721
}

# support opentelemetry-instrumentation-dbapi
self.host = host
self.port = port
self.user = user
self.database = kwargs2.get("database", "")
# otel-inst-mysqlclient uses db instead of database.
self.db = self.database
# NOTE: We have not supported semantic conventions yet.
# https://opentelemetry.io/docs/specs/semconv/database/sql/

self._server_version = tuple(
[numeric_part(n) for n in self.get_server_info().split(".")[:2]]
)

self.encoding = "ascii" # overridden in set_character_set()

if not charset:
Expand Down

0 comments on commit a4c2a49

Please sign in to comment.