From 1d93701a548c677079d227989a53d733c57b6241 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 4 Dec 2024 23:07:21 +0100 Subject: [PATCH 01/10] Add type hints to dbapi --- .../instrumentation/dbapi/__init__.py | 259 ++++++++++-------- 1 file changed, 144 insertions(+), 115 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index d8db967f47..ff5cdc5c01 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -37,12 +37,14 @@ --- """ +from __future__ import annotations + import functools import logging import re -import typing +from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar -import wrapt +from wrapt import wrap_function_wrapper from opentelemetry import trace as trace_api from opentelemetry.instrumentation.dbapi.version import __version__ @@ -55,22 +57,34 @@ from opentelemetry.trace import SpanKind, TracerProvider, get_tracer from opentelemetry.util._importlib_metadata import version as util_version +if TYPE_CHECKING: + + class wrapt: + class ObjectProxy: + def __init__(self, *args: Any, **kwargs: Any) -> None: + pass +else: + import wrapt + _DB_DRIVER_ALIASES = { "MySQLdb": "mysqlclient", } _logger = logging.getLogger(__name__) +ConnectionT = TypeVar("ConnectionT") +CursorT = TypeVar("CursorT") + def trace_integration( - connect_module: typing.Callable[..., typing.Any], + connect_module: Callable[..., Any], connect_method_name: str, database_system: str, - connection_attributes: typing.Dict = None, - tracer_provider: typing.Optional[TracerProvider] = None, + connection_attributes: dict[str, Any] | None = None, + tracer_provider: TracerProvider | None = None, capture_parameters: bool = False, enable_commenter: bool = False, - db_api_integration_factory=None, + db_api_integration_factory: type[DatabaseApiIntegration] | None = None, ): """Integrate with DB API library. https://www.python.org/dev/peps/pep-0249/ @@ -105,16 +119,16 @@ def trace_integration( def wrap_connect( name: str, - connect_module: typing.Callable[..., typing.Any], + connect_module: Callable[..., Any], connect_method_name: str, database_system: str, - connection_attributes: typing.Dict = None, + connection_attributes: dict[str, Any] | None = None, version: str = "", - tracer_provider: typing.Optional[TracerProvider] = None, + tracer_provider: TracerProvider | None = None, capture_parameters: bool = False, enable_commenter: bool = False, - db_api_integration_factory=None, - commenter_options: dict = None, + db_api_integration_factory: type[DatabaseApiIntegration] | None = None, + commenter_options: dict[str, Any] | None = None, ): """Integrate with DB API library. https://www.python.org/dev/peps/pep-0249/ @@ -141,10 +155,10 @@ def wrap_connect( # pylint: disable=unused-argument def wrap_connect_( - wrapped: typing.Callable[..., typing.Any], - instance: typing.Any, - args: typing.Tuple[typing.Any, typing.Any], - kwargs: typing.Dict[typing.Any, typing.Any], + wrapped: Callable[..., Any], + instance: Any, + args: tuple[Any, Any], + kwargs: dict[Any, Any], ): db_integration = db_api_integration_factory( name, @@ -160,7 +174,7 @@ def wrap_connect_( return db_integration.wrapped_connection(wrapped, args, kwargs) try: - wrapt.wrap_function_wrapper( + wrap_function_wrapper( connect_module, connect_method_name, wrap_connect_ ) except Exception as ex: # pylint: disable=broad-except @@ -168,7 +182,7 @@ def wrap_connect_( def unwrap_connect( - connect_module: typing.Callable[..., typing.Any], connect_method_name: str + connect_module: Callable[..., Any], connect_method_name: str ): """Disable integration with DB API library. https://www.python.org/dev/peps/pep-0249/ @@ -182,16 +196,16 @@ def unwrap_connect( def instrument_connection( name: str, - connection, + connection: ConnectionT | TracedConnectionProxy[ConnectionT], database_system: str, - connection_attributes: typing.Dict = None, + connection_attributes: dict[str, Any] | None = None, version: str = "", - tracer_provider: typing.Optional[TracerProvider] = None, + tracer_provider: TracerProvider | None = None, capture_parameters: bool = False, enable_commenter: bool = False, - commenter_options: dict = None, - connect_module: typing.Callable[..., typing.Any] = None, -): + commenter_options: dict[str, Any] | None = None, + connect_module: Callable[..., Any] | None = None, +) -> TracedConnectionProxy[ConnectionT]: """Enable instrumentation in a database connection. Args: @@ -229,7 +243,9 @@ def instrument_connection( return get_traced_connection_proxy(connection, db_integration) -def uninstrument_connection(connection): +def uninstrument_connection( + connection: ConnectionT | TracedConnectionProxy[ConnectionT], +) -> ConnectionT: """Disable instrumentation in a database connection. Args: @@ -250,22 +266,23 @@ def __init__( self, name: str, database_system: str, - connection_attributes=None, + connection_attributes: dict[str, Any] | None = None, version: str = "", - tracer_provider: typing.Optional[TracerProvider] = None, + tracer_provider: TracerProvider | None = None, capture_parameters: bool = False, enable_commenter: bool = False, - commenter_options: dict = None, - connect_module: typing.Callable[..., typing.Any] = None, + commenter_options: dict[str, Any] | None = None, + connect_module: Callable[..., Any] | None = None, ): - self.connection_attributes = connection_attributes - if self.connection_attributes is None: + if connection_attributes is None: self.connection_attributes = { "database": "database", "port": "port", "host": "host", "user": "user", } + else: + self.connection_attributes = connection_attributes self._name = name self._version = version self._tracer = get_tracer( @@ -278,17 +295,14 @@ def __init__( self.enable_commenter = enable_commenter self.commenter_options = commenter_options self.database_system = database_system - self.connection_props = {} - self.span_attributes = {} + self.connection_props: dict[str, Any] = {} + self.span_attributes: dict[str, Any] = {} self.name = "" self.database = "" self.connect_module = connect_module self.commenter_data = self.calculate_commenter_data() - def _get_db_version( - self, - db_driver, - ): + def _get_db_version(self, db_driver: str) -> str: if db_driver in _DB_DRIVER_ALIASES: return util_version(_DB_DRIVER_ALIASES[db_driver]) db_version = "" @@ -298,10 +312,8 @@ def _get_db_version( db_version = "unknown" return db_version - def calculate_commenter_data( - self, - ): - commenter_data = {} + def calculate_commenter_data(self) -> dict[str, Any]: + commenter_data: dict[str, Any] = {} if not self.enable_commenter: return commenter_data @@ -328,11 +340,7 @@ def calculate_commenter_data( libpq_version = self.connect_module.__libpq_version__ else: libpq_version = self.connect_module.pq.__build_version__ - commenter_data.update( - { - "libpq_version": libpq_version, - } - ) + commenter_data.update({"libpq_version": libpq_version}) elif self.database_system == "mysql": mysqlc_version = "" if db_driver == "MySQLdb": @@ -340,26 +348,22 @@ def calculate_commenter_data( elif db_driver == "pymysql": mysqlc_version = self.connect_module.get_client_info() - commenter_data.update( - { - "mysql_client_version": mysqlc_version, - } - ) + commenter_data.update({"mysql_client_version": mysqlc_version}) return commenter_data def wrapped_connection( self, - connect_method: typing.Callable[..., typing.Any], - args: typing.Tuple[typing.Any, typing.Any], - kwargs: typing.Dict[typing.Any, typing.Any], - ): + connect_method: Callable[..., ConnectionT], + args: tuple[Any, ...], + kwargs: dict[Any, Any], + ) -> TracedConnectionProxy[ConnectionT]: """Add object proxy to connection object.""" connection = connect_method(*args, **kwargs) self.get_connection_attributes(connection) return get_traced_connection_proxy(connection, self) - def get_connection_attributes(self, connection): + def get_connection_attributes(self, connection: object) -> None: # Populate span fields using connection for key, value in self.connection_attributes.items(): # Allow attributes nested in connection object @@ -393,39 +397,51 @@ def get_connection_attributes(self, connection): self.span_attributes[SpanAttributes.NET_PEER_PORT] = port -def get_traced_connection_proxy( - connection, db_api_integration, *args, **kwargs -): - # pylint: disable=abstract-method - class TracedConnectionProxy(wrapt.ObjectProxy): - # pylint: disable=unused-argument - def __init__(self, connection, *args, **kwargs): - wrapt.ObjectProxy.__init__(self, connection) - - def __getattribute__(self, name): - if object.__getattribute__(self, name): - return object.__getattribute__(self, name) - - return object.__getattribute__( - object.__getattribute__(self, "_connection"), name - ) +class TracedConnectionProxy(wrapt.ObjectProxy, Generic[ConnectionT]): + # pylint: disable=unused-argument + def __init__( + self, + connection: ConnectionT, + db_api_integration: DatabaseApiIntegration | None = None, + *args: Any, + **kwargs: Any, + ): + self.db_api_integration = db_api_integration + wrapt.ObjectProxy.__init__(self, connection) - def cursor(self, *args, **kwargs): - return get_traced_cursor_proxy( - self.__wrapped__.cursor(*args, **kwargs), db_api_integration - ) + def __getattribute__(self, name: str): + if object.__getattribute__(self, name): + return object.__getattribute__(self, name) - def __enter__(self): - self.__wrapped__.__enter__() - return self + return object.__getattribute__( + object.__getattribute__(self, "_connection"), name + ) - def __exit__(self, *args, **kwargs): - self.__wrapped__.__exit__(*args, **kwargs) + def cursor(self, *args: Any, **kwargs: Any): + return get_traced_cursor_proxy( + self.__wrapped__.cursor(*args, **kwargs), self.db_api_integration + ) - return TracedConnectionProxy(connection, *args, **kwargs) + def __enter__(self): + self.__wrapped__.__enter__() + return self + def __exit__(self, *args: Any, **kwargs: Any): + self.__wrapped__.__exit__(*args, **kwargs) -class CursorTracer: + +def get_traced_connection_proxy( + connection: ConnectionT, + db_api_integration: DatabaseApiIntegration | None, + *args: Any, + **kwargs: Any, +) -> TracedConnectionProxy[ConnectionT]: + return TracedConnectionProxy( + connection, db_api_integration, *args, **kwargs + ) + + +class CursorTracer(Generic[CursorT]): def __init__(self, db_api_integration: DatabaseApiIntegration) -> None: self._db_api_integration = db_api_integration self._commenter_enabled = self._db_api_integration.enable_commenter @@ -440,8 +456,8 @@ def __init__(self, db_api_integration: DatabaseApiIntegration) -> None: def _populate_span( self, span: trace_api.Span, - cursor, - *args: typing.Tuple[typing.Any, typing.Any], + cursor: CursorT, + *args: tuple[Any, ...], ): if not span.is_recording(): return @@ -463,13 +479,15 @@ def _populate_span( if self._db_api_integration.capture_parameters and len(args) > 1: span.set_attribute("db.statement.parameters", str(args[1])) - def get_operation_name(self, cursor, args): # pylint: disable=no-self-use + def get_operation_name( + self, cursor: CursorT, args: tuple[Any, ...] + ) -> str: # pylint: disable=no-self-use if args and isinstance(args[0], str): # Strip leading comments so we get the operation name. return self._leading_comment_remover.sub("", args[0]).split()[0] return "" - def get_statement(self, cursor, args): # pylint: disable=no-self-use + def get_statement(self, cursor: CursorT, args: tuple[Any, ...]): # pylint: disable=no-self-use if not args: return "" statement = args[0] @@ -479,10 +497,10 @@ def get_statement(self, cursor, args): # pylint: disable=no-self-use def traced_execution( self, - cursor, - query_method: typing.Callable[..., typing.Any], - *args: typing.Tuple[typing.Any, typing.Any], - **kwargs: typing.Dict[typing.Any, typing.Any], + cursor: CursorT, + query_method: Callable[..., Any], + *args: tuple[Any, ...], + **kwargs: dict[Any, Any], ): name = self.get_operation_name(cursor, args) if not name: @@ -546,35 +564,46 @@ def traced_execution( return query_method(*args, **kwargs) -def get_traced_cursor_proxy(cursor, db_api_integration, *args, **kwargs): - _cursor_tracer = CursorTracer(db_api_integration) +# pylint: disable=abstract-method +class TracedCursorProxy(wrapt.ObjectProxy, Generic[CursorT]): + # pylint: disable=unused-argument + def __init__( + self, + cursor: CursorT, + db_api_integration: DatabaseApiIntegration, + *args: Any, + **kwargs: Any, + ): + self._cursor_tracer = CursorTracer[CursorT](db_api_integration) + wrapt.ObjectProxy.__init__(self, cursor) - # pylint: disable=abstract-method - class TracedCursorProxy(wrapt.ObjectProxy): - # pylint: disable=unused-argument - def __init__(self, cursor, *args, **kwargs): - wrapt.ObjectProxy.__init__(self, cursor) + def execute(self, *args: Any, **kwargs: Any): + return self._cursor_tracer.traced_execution( + self.__wrapped__, self.__wrapped__.execute, *args, **kwargs + ) - def execute(self, *args, **kwargs): - return _cursor_tracer.traced_execution( - self.__wrapped__, self.__wrapped__.execute, *args, **kwargs - ) + def executemany(self, *args: Any, **kwargs: Any): + return self._cursor_tracer.traced_execution( + self.__wrapped__, self.__wrapped__.executemany, *args, **kwargs + ) - def executemany(self, *args, **kwargs): - return _cursor_tracer.traced_execution( - self.__wrapped__, self.__wrapped__.executemany, *args, **kwargs - ) + def callproc(self, *args: Any, **kwargs: Any): + return self._cursor_tracer.traced_execution( + self.__wrapped__, self.__wrapped__.callproc, *args, **kwargs + ) - def callproc(self, *args, **kwargs): - return _cursor_tracer.traced_execution( - self.__wrapped__, self.__wrapped__.callproc, *args, **kwargs - ) + def __enter__(self): + self.__wrapped__.__enter__() + return self - def __enter__(self): - self.__wrapped__.__enter__() - return self + def __exit__(self, *args, **kwargs): + self.__wrapped__.__exit__(*args, **kwargs) - def __exit__(self, *args, **kwargs): - self.__wrapped__.__exit__(*args, **kwargs) - return TracedCursorProxy(cursor, *args, **kwargs) +def get_traced_cursor_proxy( + cursor: CursorT, + db_api_integration: DatabaseApiIntegration, + *args: Any, + **kwargs: Any, +) -> TracedCursorProxy[CursorT]: + return TracedCursorProxy(cursor, db_api_integration, *args, **kwargs) From b0405741a373f60728299a57374b82770c87e1ab Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 4 Dec 2024 23:15:30 +0100 Subject: [PATCH 02/10] fix --- .../opentelemetry/instrumentation/dbapi/__init__.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index ff5cdc5c01..5cc52bf275 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -59,7 +59,7 @@ if TYPE_CHECKING: - class wrapt: + class wrapt: # pylint: disable=invalid-name class ObjectProxy: def __init__(self, *args: Any, **kwargs: Any) -> None: pass @@ -403,8 +403,6 @@ def __init__( self, connection: ConnectionT, db_api_integration: DatabaseApiIntegration | None = None, - *args: Any, - **kwargs: Any, ): self.db_api_integration = db_api_integration wrapt.ObjectProxy.__init__(self, connection) @@ -436,9 +434,7 @@ def get_traced_connection_proxy( *args: Any, **kwargs: Any, ) -> TracedConnectionProxy[ConnectionT]: - return TracedConnectionProxy( - connection, db_api_integration, *args, **kwargs - ) + return TracedConnectionProxy(connection, db_api_integration) class CursorTracer(Generic[CursorT]): @@ -571,8 +567,6 @@ def __init__( self, cursor: CursorT, db_api_integration: DatabaseApiIntegration, - *args: Any, - **kwargs: Any, ): self._cursor_tracer = CursorTracer[CursorT](db_api_integration) wrapt.ObjectProxy.__init__(self, cursor) @@ -606,4 +600,4 @@ def get_traced_cursor_proxy( *args: Any, **kwargs: Any, ) -> TracedCursorProxy[CursorT]: - return TracedCursorProxy(cursor, db_api_integration, *args, **kwargs) + return TracedCursorProxy(cursor, db_api_integration) From d6325289a6c3a3a1390531fe2809719d36f1c8c2 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 4 Dec 2024 23:24:30 +0100 Subject: [PATCH 03/10] fix --- .../src/opentelemetry/instrumentation/dbapi/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index 5cc52bf275..e544bceeb3 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -404,8 +404,8 @@ def __init__( connection: ConnectionT, db_api_integration: DatabaseApiIntegration | None = None, ): - self.db_api_integration = db_api_integration wrapt.ObjectProxy.__init__(self, connection) + self.db_api_integration = db_api_integration def __getattribute__(self, name: str): if object.__getattribute__(self, name): @@ -568,8 +568,8 @@ def __init__( cursor: CursorT, db_api_integration: DatabaseApiIntegration, ): - self._cursor_tracer = CursorTracer[CursorT](db_api_integration) wrapt.ObjectProxy.__init__(self, cursor) + self._cursor_tracer = CursorTracer[CursorT](db_api_integration) def execute(self, *args: Any, **kwargs: Any): return self._cursor_tracer.traced_execution( From 0529154f230f36570d6c40a33bc25143104b7295 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Tue, 10 Dec 2024 17:21:06 +0100 Subject: [PATCH 04/10] Fix proxy issue --- .../opentelemetry/instrumentation/dbapi/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index e544bceeb3..248a096de9 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -405,7 +405,7 @@ def __init__( db_api_integration: DatabaseApiIntegration | None = None, ): wrapt.ObjectProxy.__init__(self, connection) - self.db_api_integration = db_api_integration + self._self_db_api_integration = db_api_integration def __getattribute__(self, name: str): if object.__getattribute__(self, name): @@ -417,7 +417,8 @@ def __getattribute__(self, name: str): def cursor(self, *args: Any, **kwargs: Any): return get_traced_cursor_proxy( - self.__wrapped__.cursor(*args, **kwargs), self.db_api_integration + self.__wrapped__.cursor(*args, **kwargs), + self._self_db_api_integration, ) def __enter__(self): @@ -569,20 +570,20 @@ def __init__( db_api_integration: DatabaseApiIntegration, ): wrapt.ObjectProxy.__init__(self, cursor) - self._cursor_tracer = CursorTracer[CursorT](db_api_integration) + self._self_cursor_tracer = CursorTracer[CursorT](db_api_integration) def execute(self, *args: Any, **kwargs: Any): - return self._cursor_tracer.traced_execution( + return self._self_cursor_tracer.traced_execution( self.__wrapped__, self.__wrapped__.execute, *args, **kwargs ) def executemany(self, *args: Any, **kwargs: Any): - return self._cursor_tracer.traced_execution( + return self._self_cursor_tracer.traced_execution( self.__wrapped__, self.__wrapped__.executemany, *args, **kwargs ) def callproc(self, *args: Any, **kwargs: Any): - return self._cursor_tracer.traced_execution( + return self._self_cursor_tracer.traced_execution( self.__wrapped__, self.__wrapped__.callproc, *args, **kwargs ) From 4c87873a72da5dd268eda541f74b7afc19c38c13 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 11 Dec 2024 13:22:35 +0100 Subject: [PATCH 05/10] Remove wrapt TYPE_CHECKING wrap --- .../opentelemetry/instrumentation/dbapi/__init__.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index 248a096de9..cddf3635a8 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -42,8 +42,9 @@ import functools import logging import re -from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar +from typing import Any, Callable, Generic, TypeVar +import wrapt from wrapt import wrap_function_wrapper from opentelemetry import trace as trace_api @@ -57,15 +58,6 @@ from opentelemetry.trace import SpanKind, TracerProvider, get_tracer from opentelemetry.util._importlib_metadata import version as util_version -if TYPE_CHECKING: - - class wrapt: # pylint: disable=invalid-name - class ObjectProxy: - def __init__(self, *args: Any, **kwargs: Any) -> None: - pass -else: - import wrapt - _DB_DRIVER_ALIASES = { "MySQLdb": "mysqlclient", } From 08165d0782a1d07e8529bb61a7651cafafd18f11 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 11 Dec 2024 19:54:16 +0100 Subject: [PATCH 06/10] Add pylint disable --- .../src/opentelemetry/instrumentation/dbapi/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index cddf3635a8..33a38ce494 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -389,6 +389,7 @@ def get_connection_attributes(self, connection: object) -> None: self.span_attributes[SpanAttributes.NET_PEER_PORT] = port +# pylint: disable=abstract-method class TracedConnectionProxy(wrapt.ObjectProxy, Generic[ConnectionT]): # pylint: disable=unused-argument def __init__( From 47ff8af7c02010a65d13addc9e3f96d0ae3a2267 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 11 Dec 2024 20:00:58 +0100 Subject: [PATCH 07/10] Ignore ObjectProxy --- docs/nitpick-exceptions.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/nitpick-exceptions.ini b/docs/nitpick-exceptions.ini index 4b1b06f95b..edd3e73559 100644 --- a/docs/nitpick-exceptions.ini +++ b/docs/nitpick-exceptions.ini @@ -39,6 +39,7 @@ py-class= callable Consumer confluent_kafka.Message + ObjectProxy any= ; API From 4171bcacfe8c61a9901ab52235cedfabfcb8f014 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 11 Dec 2024 20:09:04 +0100 Subject: [PATCH 08/10] ignore more --- docs/nitpick-exceptions.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/nitpick-exceptions.ini b/docs/nitpick-exceptions.ini index edd3e73559..b6339875f3 100644 --- a/docs/nitpick-exceptions.ini +++ b/docs/nitpick-exceptions.ini @@ -39,6 +39,8 @@ py-class= callable Consumer confluent_kafka.Message + opentelemetry.instrumentation.dbapi.ConnectionT + opentelemetry.instrumentation.dbapi.CursorT ObjectProxy any= From d731ca49b8bce7eeb6d5c18f99fd4d07c4dea7dc Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 11 Dec 2024 20:17:54 +0100 Subject: [PATCH 09/10] nitpick again --- docs/nitpick-exceptions.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/nitpick-exceptions.ini b/docs/nitpick-exceptions.ini index b6339875f3..0032be64b6 100644 --- a/docs/nitpick-exceptions.ini +++ b/docs/nitpick-exceptions.ini @@ -39,8 +39,6 @@ py-class= callable Consumer confluent_kafka.Message - opentelemetry.instrumentation.dbapi.ConnectionT - opentelemetry.instrumentation.dbapi.CursorT ObjectProxy any= @@ -69,6 +67,8 @@ any= py-obj= opentelemetry.propagators.textmap.CarrierT + opentelemetry.instrumentation.dbapi.ConnectionT + opentelemetry.instrumentation.dbapi.CursorT py-func= poll From f6d4266304c9e172a31d7f90b8e3533756077123 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Fri, 13 Dec 2024 14:17:03 +0100 Subject: [PATCH 10/10] Add changelog entry and py.typed --- CHANGELOG.md | 3 +++ .../src/opentelemetry/instrumentation/dbapi/py.typed | 0 2 files changed, 3 insertions(+) create mode 100644 instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/py.typed diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b8d39ff0e..014e1afdfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- `opentelemetry-instrumentation-dbapi` Move `TracedCursorProxy` and `TracedConnectionProxy` to the module level + ([#3068](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3068)) + ## Version 1.29.0/0.50b0 (2024-12-11) ### Added diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/py.typed b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/py.typed new file mode 100644 index 0000000000..e69de29bb2