Repository: redis/redis-py
File: redis/observability/metrics.py (Python)

Code before:
        self.connection_create_time.record(duration_seconds, attributes=attrs)

    def record_connection_wait_time(
        self,
        pool_name: str,
        duration_seconds: float,
    ) -> None:
        """
        Record time taken to obtain a connection from the pool.

        Args:
            pool_name: Connection pool name
            duration_seconds: Wait time in seconds
        """
        if not hasattr(self, "connection_wait_time"):
            return

        attrs = self.attr_builder.build_connection_attributes(pool_name=pool_name)
        self.connection_wait_time.record(duration_seconds, attributes=attrs)

    # Command execution metric recording methods

    @deprecated_args(
        args_to_warn=["batch_size"],
        reason="The batch_size argument is no longer used and will be removed in the next major version.",
        version="7.2.1",
    )
    def record_operation_duration(
        self,
        command_name: str,
        duration_seconds: float,
        server_address: Optional[str] = None,
        server_port: Optional[int] = None,
        db_namespace: Optional[int] = None,
        batch_size: Optional[int] = None,
        error_type: Optional[Exception] = None,
        network_peer_address: Optional[str] = None,
        network_peer_port: Optional[int] = None,
        retry_attempts: Optional[int] = None,
        is_blocking: Optional[bool] = None,
    ) -> None:
        """
        Record command execution duration.

        Args:
            command_name: Redis command name (e.g., 'GET', 'SET', 'MULTI')
            duration_seconds: Execution time in seconds
            server_address: Redis server address
            server_port: Redis server port
            db_namespace: Redis database index
            batch_size: Number of commands in batch (for pipelines/transactions)

Review comment (suggestion):
The deprecation warning indicates "Deprecated since version 7.2.1", but the project version in redis/__init__.py is currently 7.1.1. This makes the warning misleading (it refers to a future release). Consider setting `version=` to the current release where this deprecation is introduced, or omitting it.
```suggestion
        version="7.1.1",
```

Code after:
        self.connection_create_time.record(duration_seconds, attributes=attrs)

    def record_connection_wait_time(
        self,
        pool_name: str,
        duration_seconds: float,
    ) -> None:
        """
        Record time taken to obtain a connection from the pool.

        Args:
            pool_name: Connection pool name
            duration_seconds: Wait time in seconds
        """
        if not hasattr(self, "connection_wait_time"):
            return

        attrs = self.attr_builder.build_connection_attributes(pool_name=pool_name)
        self.connection_wait_time.record(duration_seconds, attributes=attrs)

    # Command execution metric recording methods

    @deprecated_args(
        args_to_warn=["batch_size"],
        reason="The batch_size argument is no longer used and will be removed in the next major version.",
        version="7.2.1",
    )
    def record_operation_duration(
        self,
        command_name: str,
        duration_seconds: float,
        server_address: Optional[str] = None,
        server_port: Optional[int] = None,
        db_namespace: Optional[int] = None,
        batch_size: Optional[int] = None,  # noqa
        error_type: Optional[Exception] = None,
        network_peer_address: Optional[str] = None,
        network_peer_port: Optional[int] = None,
        retry_attempts: Optional[int] = None,
        is_blocking: Optional[bool] = None,
    ) -> None:
        """
        Record command execution duration.

        Args:
            command_name: Redis command name (e.g., 'GET', 'SET', 'MULTI')
            duration_seconds: Execution time in seconds
            server_address: Redis server address
            server_port: Redis server port
            db_namespace: Redis database index
            batch_size: Number of commands in batch (for pipelines/transactions)