nlopes / libhoney-rust

Rust library for sending data to Honeycomb
MIT License
23 stars 16 forks source link

Reuse HTTP connections between batches #69

Closed ramosbugs closed 3 years ago

ramosbugs commented 3 years ago

Currently, send_batch creates a new reqwest client for each batch, which results in creating a new HTTPS connection for each batch. This PR reuses the same reqwest client across batches, which reduces latency by reusing connections.

This pattern is consistent with the reqwest docs:

The Client holds a connection pool internally, so it is advised that you create one and reuse it.

This PR also adds some trace-level logging, which should have no effect unless trace logs are explicitly enabled for the log crate.

nlopes commented 3 years ago

Thank you @ramosbugs!