> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 배치 로깅

> log_turn과 log_conversation을 사용하여 완료된 턴과 대화 전체를 사후에 내보냅니다.

`tracing` 모듈을 통해 다음 항목에 액세스할 수 있습니다:

```python theme={"system"}
from coreweave.forge.agentlens import tracing
```

<h2 id="log_turn">
  log\_turn
</h2>

```python theme={"system"}
def log_turn(
    *,
    conversation_id: str,
    agent_name: str = '',
    conversation_name: str = '',
    model: str = '',
    agent_id: str = '',
    agent_description: str = '',
    agent_version: str = '',
    messages: Union[list[Message], None] = None,
    output_messages: Union[list[Message], None] = None,
    system_instructions: Union[list[str], None] = None,
    spans: Union[list[Union[LLM, Tool, SubAgent]], None] = None,
    started_at: Union[datetime, None] = None,
    ended_at: Union[datetime, None] = None,
    include_content: bool = True,
    continue_parent_trace: bool = False,
    attributes: Attributes = None,
) -> LogResult: ...
```

턴 하나와 그 하위 span을 명령형 방식으로 OTel에 내보냅니다.

컨텍스트 관리자를 사용할 수 없는 경우(상태를 유지하지 않는 컨테이너, callback,
큐 워커)에 사용하세요. 전달하는 각 하위 span에는 `started_at` /
`ended_at`이 설정되어 있어야 하며, 내보내는 OTel span의 타임스탬프는 이 필드 값을 따릅니다.
턴에 자체 타임스탬프가 없으면 하위 span 중 가장 이른/가장 늦은 타임스탬프를 사용하고, 이것도 없으면 `now()`를
사용합니다. `agent_id` / `agent_description` /
`agent_version`은 스트리밍 경로와 동일하게 동작합니다.

`attributes`는 내보내는 모든 span에 기록됩니다. 스트리밍 경로에서는 이 값을
활성 대화에서 읽어 옵니다. semconv가 아닌 맞춤형 키를 사용하세요.
span 자체의 `gen_ai.*` / `weave.*` 속성과 충돌하는 키는
지원되지 않습니다(어느 값이 적용될지는 경로에 따라 달라집니다).

`messages`는 턴 입력을, `output_messages`는
최종 에이전트 응답을 동일한 `invoke_agent` span에 기록합니다.

<h2 id="log_conversation">
  log\_conversation
</h2>

```python theme={"system"}
def log_conversation(
    *,
    turns: list[Turn],
    conversation_id: str = '',
    conversation_name: str = '',
    agent_name: str = '',
    model: str = '',
    agent_id: str = '',
    agent_description: str = '',
    agent_version: str = '',
    include_content: bool = True,
    continue_parent_trace: bool = False,
    attributes: Attributes = None,
) -> LogResult: ...
```

완전한 대화를 명령형 방식으로 내보냅니다.

각 Turn의 `.spans` 속성에 해당 Turn의 하위 항목이 담깁니다. `conversation_id`가 비어 있으면
자동으로 생성됩니다. 기본적으로 각 턴마다 별도의 OTel 트레이스가 생성됩니다.
`agent_name` / `model` / `agent_id` / `agent_description` /
`agent_version`은 대화 수준의 기본값입니다. Turn 자체의 값이 우선하며,
Turn에 값이 비어 있을 때만 대화의 값으로 채워집니다. 대화의
`continue_parent_trace`는 모든 턴에 적용되며 Turn별 값보다
우선합니다.

`attributes`는 내보내는 모든 span에 기록됩니다. semconv가 아닌 맞춤형
키를 사용하세요. span 자체의 `gen_ai.*` / `weave.*` 속성과
충돌하는 키는 지원되지 않습니다(어느 값이 적용될지는 경로에 따라 달라집니다).

<h2 id="logresult">
  LogResult
</h2>

```python theme={"system"}
class LogResult(BaseModel): ...
```

배치 log\_\* 호출의 결과입니다.

`LogResult`는 Pydantic 모델입니다. 인스턴스를 생성할 때 아래 필드를 키워드 인수로 지정할 수 있습니다.

**필드**

| 필드 | 유형 | 기본값 |
| - | - | - |
| `conversation_id` | `str` | `''` |
| `trace_ids` | `list[str]` | `[]` |
| `root_span_ids` | `list[str]` | `[]` |
| `span_count` | `int` | `0` |
