Skip to main content

Module tcp_logger

Module tcp_logger 

Source
Expand description

The tcp-logger node — ships per-request access-log entries to a remote TCP endpoint (a log collector such as Logstash, Fluentd, or a raw TCP sink), mirroring APISIX’s tcp-logger plugin.

Entries are built with the shared build_entry helper, buffered in a BatchSink, and delivered by a background task that opens a fresh [tokio::net::TcpStream] per flush, writes each entry as one newline-delimited JSON object, and closes the connection. Delivery is fire-and-forget on the request path: Plugin::execute never blocks on the network and always returns the context unchanged, so this node should be placed in the response pipeline after the upstream node where the final status and body size are available.

§Deviations from APISIX

  • Entries are always sent as newline-delimited JSON (one object per line), rather than APISIX’s “single object when batch_max_size == 1, JSON array otherwise” shape. This keeps the wire format stable regardless of batching.
  • tls / tls_options are not yet supported; configuring tls: true is rejected at config load. Plain TCP only.

Structs§

TcpFlusher 🔒
BatchFlusher that connects to host:port and writes the batch.
TcpLoggerPlugin
The tcp-logger plugin node.

Functions§

entries_to_lines 🔒
Serializes each entry as one line of JSON, newline-terminated, and concatenates them into the payload written to the socket. Pure and independent of the network so it can be unit-tested directly.