async def _create_async_stream_processor(response, span):
    """Create an async generator that processes a stream while collecting telemetry."""
    accumulated_content = ""
    finish_reason = None
    usage = None

    async for chunk in response:
        content, chunk_finish_reason, chunk_usage = _process_streaming_chunk(chunk)
        if content:
            accumulated_content += content
        if chunk_finish_reason:
            finish_reason = chunk_finish_reason
        if chunk_usage:
            usage = chunk_usage
        yield chunk

    if span.is_recording():
        _set_streaming_response_attributes(
            span, accumulated_content, finish_reason, usage
        )
        span.set_status(Status(StatusCode.OK))
    span.end()
Create an async generator that processes a stream while collecting telemetry.
packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/__init__.py