> ## 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.

# セットアップとシャットダウン

> init、force_flush、shutdown、TracingSession を使用して、トレースの開始、フラッシュ、停止を行います。

これらには `tracing` モジュールからアクセスします。

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

<h2 id="init">
  init
</h2>

```python theme={"system"}
def init(
    project_name: str,
    *,
    api_key: Union[str, None] = None,
    base_url: Union[str, None] = None,
    service_name: str = 'coreweave-forge-sdk',
    autopatch_integrations: bool = True,
) -> TracingSession: ...
```

パッケージが作成したエージェント スパンを Agent Lens project にエクスポートする処理を開始します。

`project_name` は `entity/project` の形式で指定する必要があります。このパッケージは、デフォルトの entity を検出するために
W\&B のアカウント API に依存しないよう意図的に設計されています。認証情報は
`api_key`、`WANDB_API_KEY`、または `.netrc` 内の W\&B ホスト エントリから取得されます。
`autopatch_integrations=True` を指定すると、すでに `sys.modules` に読み込まれているサポート対象のプロバイダー SDK にパッチを適用し、
後からインポートされるプロバイダーも監視します。
再初期化すると、以前のセッションがフラッシュされ、新しいスパンは新しい
project にルーティングされます。まだ開いているスパンは、開始時の project へ引き続きエクスポートされます。
以前のセッションは、次回の `init` または
`shutdown` の呼び出し時にクローズされます。

<h2 id="force_flush">
  force\_flush
</h2>

```python theme={"system"}
def force_flush(timeout_millis: int = 30000) -> bool: ...
```

<h2 id="shutdown">
  shutdown
</h2>

```python theme={"system"}
def shutdown() -> None: ...
```

<h2 id="tracingsession">
  TracingSession
</h2>

```python theme={"system"}
@dataclass
class TracingSession: ...
```

OTLP プロバイダーと、そのバックグラウンドエクスポートワーカーを所有します。

**フィールド**

| フィールド | タイプ | デフォルト |
| - | - | - |
| `provider` | `TracerProvider` | 必須 |
| `endpoint` | `str` | 必須 |
| `project_id` | `str` | 必須 |

<h3 id="tracingsessionforce_flush">
  TracingSession.force\_flush
</h3>

```python theme={"system"}
def force_flush(timeout_millis: int = 30000) -> bool: ...
```

<h3 id="tracingsessionshutdown">
  TracingSession.shutdown
</h3>

```python theme={"system"}
def shutdown() -> None: ...
```
