Principle:Wandb Weave Session Finalization
| Knowledge Sources | |
|---|---|
| Domains | Observability, Resource_Management |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
A session teardown mechanism that flushes pending trace data and releases client resources.
Description
Session Finalization ensures that all buffered trace data is flushed to the backend before the application exits. It clears the global client reference, unregisters import hooks, and releases resources. Without finalization, traces recorded near the end of a session may be lost.
Usage
Use this principle at the end of a tracing session, typically before application shutdown. It is the complement to Client Initialization. After finalization, @weave.op decorated functions will no longer be traced until weave.init() is called again.
Theoretical Basis
Session finalization follows the acquire-use-release resource management pattern:
- Flush: Send all buffered trace data to the backend.
- Unregister: Remove import hooks and integration patches.
- Release: Clear the global client reference.
This ensures data integrity by guaranteeing that all traces are persisted before the client is destroyed.