pub struct TcpBuilder { /* private fields */ }
Expand description
Builder for creating and installing a TCP recorder/exporter.
Implementations§
Source§impl TcpBuilder
impl TcpBuilder
Sourcepub fn new() -> TcpBuilder
pub fn new() -> TcpBuilder
Creates a new TcpBuilder
.
Sourcepub fn listen_address<A>(self, addr: A) -> TcpBuilderwhere
A: Into<SocketAddr>,
pub fn listen_address<A>(self, addr: A) -> TcpBuilderwhere
A: Into<SocketAddr>,
Sets the listen address.
The exporter will accept connections on this address and immediately begin forwarding metrics to the client.
Defaults to 0.0.0.0:5000
.
Sourcepub fn buffer_size(self, size: Option<usize>) -> TcpBuilder
pub fn buffer_size(self, size: Option<usize>) -> TcpBuilder
Sets the buffer size for internal operations.
The buffer size controls two operational aspects: the number of metrics processed per iteration of the event loop, and the number of buffered metrics each client can hold.
This setting allows trading off responsiveness for throughput, where a smaller buffer size will ensure that metrics are pushed to clients sooner, versus a larger buffer size that allows us to push more at a time.
As well, the larger the buffer, the more messages a client can temporarily hold. Clients have a circular buffer implementation so if their buffers are full, metrics will be dropped as necessary to avoid backpressure in the recorder.
Sourcepub fn install(self) -> Result<(), Error>
pub fn install(self) -> Result<(), Error>
Installs the recorder and exporter.
An error will be returned if there’s an issue with creating the TCP server or with installing the recorder as the global recorder.
Sourcepub fn build(self) -> Result<TcpRecorder, Error>
pub fn build(self) -> Result<TcpRecorder, Error>
Builds and installs the exporter, but returns the recorder.
In most cases, users should prefer to use TcpBuilder::install
to create and install
the recorder and exporter automatically for them. If a caller is combining recorders,
however, then this method allows the caller the flexibility to do so.