Skip to content

Commit

Permalink
mysql uses updated dbapi.instrument_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Nov 26, 2024
1 parent 19bfd7c commit ee907e2
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
import typing

import mysql.connector
import wrapt

from opentelemetry import trace as trace_api
from opentelemetry.instrumentation import dbapi
Expand Down Expand Up @@ -180,22 +179,19 @@ def instrument_connection(
Returns:
An instrumented connection.
"""
if isinstance(connection, wrapt.ObjectProxy):
_logger.warning("Connection already instrumented")
return connection

db_integration = DatabaseApiIntegration(
return dbapi.instrument_connection(
__name__,
connection,
self._DATABASE_SYSTEM,
self._CONNECTION_ATTRIBUTES,
version=__version__,
tracer_provider=tracer_provider,
enable_commenter=enable_commenter,
commenter_options=commenter_options,
connect_module=mysql.connector,
db_api_integration_factory=DatabaseApiIntegration,
get_cnx_proxy=get_traced_connection_proxy,
)
db_integration.get_connection_attributes(connection)
return get_traced_connection_proxy(connection, db_integration)

def uninstrument_connection(
self,
Expand Down

0 comments on commit ee907e2

Please sign in to comment.