def parse()

in instrumentation/elastic-opentelemetry-instrumentation-openai/src/opentelemetry/instrumentation/openai/wrappers.py [0:0]


    def parse(self):
        """
        Handles direct parse() call on the client in order to maintain instrumentation on the parsed iterator.
        """
        parsed_iterator = self.__wrapped__.parse()

        parsed_wrapper = StreamWrapper(
            stream=parsed_iterator,
            span=self.span,
            span_attributes=self.span_attributes,
            capture_message_content=self.capture_message_content,
            event_attributes=self.event_attributes,
            event_logger=self.event_logger,
            start_time=self.start_time,
            token_usage_metric=self.token_usage_metric,
            operation_duration_metric=self.operation_duration_metric,
        )

        # Handle original sync/async iterators accordingly
        if hasattr(parsed_iterator, "__aiter__"):
            return parsed_wrapper.__aiter__()

        return parsed_wrapper.__iter__()