|
113 | 113 |
|
114 | 114 | import mysql.connector |
115 | 115 | import wrapt |
116 | | -from mysql.connector.cursor_cext import CMySQLCursor |
117 | 116 |
|
118 | 117 | from opentelemetry import trace as trace_api |
119 | 118 | from opentelemetry.instrumentation import dbapi |
@@ -222,7 +221,7 @@ def wrapped_connection( |
222 | 221 | args: typing.Tuple[typing.Any, typing.Any], |
223 | 222 | kwargs: typing.Dict[typing.Any, typing.Any], |
224 | 223 | ): |
225 | | - """Add object proxy to connection object.""" |
| 224 | + """Add object proxy to connection object that checks cursor type.""" |
226 | 225 | connection = connect_method(*args, **kwargs) |
227 | 226 | self.get_connection_attributes(connection) |
228 | 227 | return get_traced_connection_proxy(connection, self) |
@@ -363,44 +362,3 @@ def __exit__(self, *args, **kwargs): |
363 | 362 | self.__wrapped__.__exit__(*args, **kwargs) |
364 | 363 |
|
365 | 364 | return TracedCursorProxy(cursor, *args, **kwargs) |
366 | | - |
367 | | - |
368 | | -def _new_cursor_factory( |
369 | | - db_api: DatabaseApiIntegration = None, |
370 | | - cursor_factory: CMySQLCursor = None, |
371 | | - tracer_provider: trace_api.TracerProvider = None, |
372 | | - enable_commenter: bool = False, |
373 | | -): |
374 | | - if not db_api: |
375 | | - db_api = DatabaseApiIntegration( |
376 | | - __name__, |
377 | | - MySQLInstrumentor._DATABASE_SYSTEM, |
378 | | - MySQLInstrumentor._CONNECTION_ATTRIBUTES, |
379 | | - version=__version__, |
380 | | - tracer_provider=tracer_provider, |
381 | | - ) |
382 | | - |
383 | | - # Latter is base class for all mysql-connector cursors |
384 | | - cursor_factory = cursor_factory or CMySQLCursor |
385 | | - _cursor_tracer = CursorTracer( |
386 | | - db_api, |
387 | | - enable_commenter, |
388 | | - ) |
389 | | - |
390 | | - class TracedCursorFactory(cursor_factory): |
391 | | - def execute(self, *args, **kwargs): |
392 | | - return _cursor_tracer.traced_execution( |
393 | | - self, super().execute, *args, **kwargs |
394 | | - ) |
395 | | - |
396 | | - def executemany(self, *args, **kwargs): |
397 | | - return _cursor_tracer.traced_execution( |
398 | | - self, super().executemany, *args, **kwargs |
399 | | - ) |
400 | | - |
401 | | - def callproc(self, *args, **kwargs): |
402 | | - return _cursor_tracer.traced_execution( |
403 | | - self, super().callproc, *args, **kwargs |
404 | | - ) |
405 | | - |
406 | | - return TracedCursorFactory |
0 commit comments