Skip to content

Commit ae1dd8a

Browse files
authored
add LineBuffer usage advice to spectator-go
1 parent 72040ed commit ae1dd8a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/spectator/lang/go/usage.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Writers can be configured through `spectator.Config.Location`.
184184

185185
Possible values are:
186186

187-
* `""` - Empty string will default to `udp`.
187+
* `""` - Empty string will default to `udp`, with the `LineBuffer` disabled by default.
188188
* `none` - A no-op writer that does nothing. Used to disable metrics collection.
189189
* `memory` - Write to memory. Useful for testing.
190190
* `stderr` - Write to standard error for the process.
@@ -200,6 +200,17 @@ the environment variable takes precedence over the passed config.
200200

201201
The environment variable `SPECTATOR_OUTPUT_LOCATION` can be set to `none` to disable metrics collection.
202202

203+
## Line Buffer
204+
205+
The `NewConfigWithBuffer` factory function takes a `bufferSize` parameter that configures an optional
206+
`LineBuffer`, which caches protocol lines locally, before flushing them to `spectatord`. Flushes occur
207+
under two conditions: (1) the buffer size is exceeded, or (2) five seconds has elapsed. The buffer is
208+
available for the `UdpWriter` and the `UnixgramWriter`, where performance matters most. The `LineBuffer`
209+
is disabled by default (with size zero) in the standard `NewConfig` factory function, to ensure that the
210+
default operation of the library works under most circumstances. For high-performance scenarios, a 60KB
211+
buffer size is recommended. The maximum buffer size for udp sockets and unix domain sockets on Linux is
212+
64KB, so stay under this limit.
213+
203214
## Batch Usage
204215

205216
When using `spectator-go` to report metrics from a batch job, ensure that the batch job runs for at

0 commit comments

Comments
 (0)