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

# SDK Lifecycle

> [tab] TypeScript
>
> Laminar.flush()
>
> Flush pending spans to the backend.
>
> ```typescript theme={null}
> // At end of script or Lambda handler
> await Laminar.flush();
> ```
>
> **Returns:** `Promise<void>`
>
> **When to use:**
>
> * End of CLI scripts
> * End of serverless function handlers
> * Before process exit
>
> **When NOT to use:**
>
> * In web server request handlers (degrades performance)
>
> ***
>
> Laminar.shutdown()
>
> Flush spans and shut down tracing.
>
> ```typescript theme={null}
> await Laminar.shutdown();
> // Can call Laminar.initialize() again if needed
> ```
>
> **Returns:** `Promise<void>`
>
> **Note:** Force flushes, clears config/context, releases resources. Can re-initialize afterward.
>
> ***
>
> Laminar.getHttpUrl()
>
> Return the configured HTTP URL.
>
> **Returns:** `string`
>
> ***
>
> Laminar.getProjectApiKey()
>
> Return the configured project API key.
>
> **Returns:** `string`

> [tab] Python
>
> Laminar.flush()
>
> Flush pending spans to the backend.
>
> ```python theme={null}
> # At end of script
> Laminar.flush()
> ```
>
> **Returns:** `bool` — Success status (`False` if Tracevell is not initialized)
>
> **When to use:**
>
> * End of CLI scripts
> * Graceful shutdown of web servers
>
> **When NOT to use:**
>
> * In web server request handlers (degrades performance)
>
> ***
>
> Laminar.force\_flush()
>
> Force flush spans, blocking until complete. Resets context.
>
> ```python theme={null}
> # In AWS Lambda handler
> def handler(event, context):
>     Laminar.initialize()
>     result = process(event)
>     Laminar.force_flush()  # Blocks until spans exported
>     return result
> ```
>
> **Returns:** `None`
>
> **Use for:** AWS Lambda and serverless where background threads may be killed.
>
> **Behavior:** Shuts down and reinitializes span processor internally. Clears isolated context—subsequent spans start new traces.
>
> ***
>
> Laminar.shutdown()
>
> Flush spans and shut down tracing.
>
> ```python theme={null}
> Laminar.shutdown()
> # Cannot re-initialize in same process
> ```
>
> **Returns:** `None`
>
> **Note:** Unlike JavaScript SDK, Python SDK cannot re-initialize after shutdown.
>
> ***
>
> Edge Cases
>
> * **Input/output size:** Values >10MB are truncated to the 10MB limit with a trailing `...[Tracevell: truncated]` marker. The recorded value is no longer valid JSON, but the start of the payload is preserved.
> * **Uninitialized:** If `Laminar.initialize()` not called:
>   * `@observe()` returns original function unchanged
>   * Manual span methods return `NonRecordingSpan`
> * **Generators:** `@observe()` aggregates all yielded values for output recording
> * **Span lifecycle:** `start_span`/`start_active_span` must end in LIFO order. Violating can corrupt context hierarchy.
> * **Context isolation:** By default, `@observe()` uses isolated context. Set `preserve_global_context=True` to continue existing OTEL traces.
> * **force\_flush:** Clears isolated context. Subsequent spans start new traces.
>
> ***
>
> Laminar.get\_base\_http\_url()
>
> Return the configured OTLP HTTP URL.
>
> **Returns:** `str | None`
>
> ***
>
> Laminar.get\_project\_api\_key()
>
> Return the configured project API key.
>
> **Returns:** `str | None`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.