#metrics-exporter #metrics #tcp #telemetry

metrics-exporter-tcp

A metrics-compatible exporter that outputs metrics to clients over TCP

16 releases (8 breaking)

0.9.0 Dec 24, 2023
0.8.0 Apr 16, 2023
0.7.0 Jul 21, 2022
0.6.0 Jan 15, 2022
0.1.0-alpha.2 Jul 27, 2020

#793 in Debugging

Download history 340/week @ 2023-12-18 28/week @ 2023-12-25 97/week @ 2024-01-01 108/week @ 2024-01-08 773/week @ 2024-01-15 1090/week @ 2024-01-22 1445/week @ 2024-01-29 795/week @ 2024-02-05 645/week @ 2024-02-12 662/week @ 2024-02-19 529/week @ 2024-02-26 416/week @ 2024-03-04 311/week @ 2024-03-11 318/week @ 2024-03-18 346/week @ 2024-03-25 627/week @ 2024-04-01

1,606 downloads per month

MIT license

135KB
2K SLoC

metrics-exporter-tcp

conduct-badge downloads-badge release-badge docs-badge license-badge

metrics-exporter-tcp is a metrics-compatible exporter that outputs metrics to clients over TCP.

code of conduct

NOTE: All conversations and contributions to this project shall adhere to the Code of Conduct.


lib.rs:

A metrics-compatible exporter that outputs metrics to clients over TCP.

This exporter creates a TCP server, that when connected to, will stream individual metrics to the client using a Protocol Buffers encoding.

Backpressure

The exporter has configurable buffering, which allows users to trade off how many metrics they want to be queued up at any given time. This buffer limit applies both to incoming metrics, as well as the individual buffers for each connected client.

By default, the buffer limit is set at 1024 metrics. When the incoming buffer -- metrics being fed to the exported -- is full, metrics will be dropped. If a client's buffer is full, potentially due to slow network conditions or slow processing, then messages in the client's buffer will be dropped in FIFO order in order to allow the exporter to continue fanning out metrics to clients.

If no buffer limit is set, then te exporter will ingest and enqueue as many metrics as possible, potentially up until the point of memory exhaustion. A buffer limit is advised for this reason, even if it is many multiples of the default.

Encoding

Metrics are encoded using Protocol Buffers. The protocol file can be found in the repository at proto/event.proto.

Usage

The TCP exporter can be constructed by creating a TcpBuilder, configuring it as needed, and calling TcpBuilder::install to both spawn the TCP server as well as install the exporter globally.

If necessary, the recorder itself can be returned so that it can be composed separately, while still installing the TCP server itself, by calling TcpBuilder::build.

// Install the exporter directly:
let builder = TcpBuilder::new();
builder.install().expect("failed to install TCP exporter");

// Or install the TCP server and get the recorder:
let builder = TcpBuilder::new();
let recorder = builder.build().expect("failed to install TCP exporter");

Dependencies

~2–14MB
~131K SLoC