Repository: jina-ai/jina
File: jina/serve/runtimes/request_handlers/worker_request_handler.py (Python)

Code before:

            WorkerRequestHandler.replace_docs(
                requests[0], docs, self.args.output_array_type
            )
        return docs

    async def handle(
        self, requests: List['DataRequest'], tracing_context: Optional['Context'] = None
    ) -> DataRequest:
        """Initialize private parameters and execute private loading functions.

        :param requests: The messages to handle containing a DataRequest
        :param tracing_context: Optional OpenTelemetry tracing context from the originating request.
        :returns: the processed message
        """
        # skip executor if endpoints mismatch
        if (
            requests[0].header.exec_endpoint not in self._executor.requests
            and __default_endpoint__ not in self._executor.requests
        ):
            self.logger.debug(
                f'skip executor: mismatch request, exec_endpoint: {requests[0].header.exec_endpoint}, requests: {self._executor.requests}'
            )
            return requests[0]

        self._record_request_size_prometheus(requests)

        params = self._parse_params(requests[0].parameters, self._executor.metas.name)
        docs = WorkerRequestHandler.get_docs_from_request(
            requests,
            field='docs',
        )

        # executor logic
        return_data = await self._executor.__acall__(
            req_endpoint=requests[0].header.exec_endpoint,
            docs=docs,
            parameters=params,
            docs_matrix=WorkerRequestHandler.get_docs_matrix_from_request(
                requests,
                field='docs',
            ),
            tracing_context=tracing_context,
        )

        docs = self._set_result(requests, return_data, docs)

        self._record_docs_processed_prometheus(requests, docs)
        self._record_response_size_prometheus(requests)

        return requests[0]

Review comment (suggestion):
```suggestion
        self._record_request_size_monitoring(requests)
```

Code after:

        WorkerRequestHandler.replace_docs(
            requests[0], docs, self.args.output_array_type
        )
        return docs

    async def handle(
        self, requests: List['DataRequest'], tracing_context: Optional['Context'] = None
    ) -> DataRequest:
        """Initialize private parameters and execute private loading functions.

        :param requests: The messages to handle containing a DataRequest
        :param tracing_context: Optional OpenTelemetry tracing context from the originating request.
        :returns: the processed message
        """
        # skip executor if endpoints mismatch
        if (
            requests[0].header.exec_endpoint not in self._executor.requests
            and __default_endpoint__ not in self._executor.requests
        ):
            self.logger.debug(
                f'skip executor: mismatch request, exec_endpoint: {requests[0].header.exec_endpoint}, requests: {self._executor.requests}'
            )
            return requests[0]

        self._record_request_size_monitoring(requests)

        params = self._parse_params(requests[0].parameters, self._executor.metas.name)
        docs = WorkerRequestHandler.get_docs_from_request(
            requests,
            field='docs',
        )

        # executor logic
        return_data = await self._executor.__acall__(
            req_endpoint=requests[0].header.exec_endpoint,
            docs=docs,
            parameters=params,
            docs_matrix=WorkerRequestHandler.get_docs_matrix_from_request(
                requests,
                field='docs',
            ),
            tracing_context=tracing_context,
        )

        docs = self._set_result(requests, return_data, docs)

        self._record_docs_processed_monitoring(requests, docs)
        self._record_response_size_monitoring(requests)

        return requests[0]