def _set_streaming_response_attributes(
    span, accumulated_content, finish_reason=None, usage=None
):
    """Set span attributes for accumulated streaming response."""
    if not span.is_recording():
        return

    prefix = f"{SpanAttributes.LLM_COMPLETIONS}.0"
    set_span_attribute(span, f"{prefix}.role", "assistant")
    set_span_attribute(span, f"{prefix}.content", accumulated_content)
    if finish_reason:
        set_span_attribute(span, f"{prefix}.finish_reason", finish_reason)

    if usage:
        set_span_attribute(
            span, SpanAttributes.LLM_USAGE_COMPLETION_TOKENS, usage.completion_tokens
        )
        set_span_attribute(
            span, SpanAttributes.LLM_USAGE_PROMPT_TOKENS, usage.prompt_tokens
        )
        set_span_attribute(
            span, SpanAttributes.LLM_USAGE_TOTAL_TOKENS, usage.total_tokens
        )
Set span attributes for accumulated streaming response.
packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/__init__.py