Features
Batching and flush
When Dock sends your captures, and how to make sure none are lost when your process exits.
capture doesn't make a network call. It adds the event to a buffer in your process, and Dock sends the buffer to Docklee in batches. Your app never waits on Docklee to capture.
Short-lived processes such as scripts, jobs, and serverless functions must flush or close Dock before they exit. Events still in the buffer are never sent.
When a batch is sent
| Trigger | Python | TypeScript |
|---|---|---|
The buffer reaches buffer_size events | Yes | Yes |
Every flushInterval milliseconds | No | Yes, every 5,000 by default |
You call flush_sync() or flush() | Yes | Yes |
You call close() | Yes | Yes |
Flush and close
from docklee import Dock
dock = Dock(buffer_size=25)
for message in messages:
dock.capture(message, type="conversation")
result = dock.flush_sync()| Method | Python | TypeScript |
|---|---|---|
| Send the buffer and wait | flush_sync(), or await flush() | await flush() |
| Send the buffer and stop | await close() | await close() |
In TypeScript, Dock runs a timer while it's open. Call close() when you're done so your process can exit.
When a batch fails
With flush_sync() in Python and flush() in TypeScript, a failed batch goes back into the buffer and is sent with the next flush. Both return the batch result on success, and None or null on failure.
Before giving up, the SDK retries timeouts, connection errors, and the statuses 408, 409, 429, 500, 502, 503, and 504. It waits 0.5 seconds before the first retry and doubles the wait each time, up to 8 seconds.
Tuning
| Setting | Python | TypeScript | Default |
|---|---|---|---|
| Events per batch | buffer_size | bufferSize | 10 |
| Timer interval | none | flushInterval | 5000 milliseconds |
| Retries per request | max_retries | maxRetries | 3 |
| Request timeout | timeout (seconds) | timeout (milliseconds) | 30 seconds |
A batch holds up to 100 events, so keep buffer_size at 100 or below.
Next steps
Your captures are reaching Docklee. See what it does with them next.