MCPcopy
hub / github.com/segmentio/kafka-go / Stats

Method Stats

writer.go:878–905  ·  view source on GitHub ↗

Stats returns a snapshot of the writer stats since the last time the method was called, or since the writer was created if it is called for the first time. A typical use of this method is to spawn a goroutine that will periodically call Stats on a kafka writer and report the metrics to a stats coll

()

Source from the content-addressed store, hash-verified

876// call Stats on a kafka writer and report the metrics to a stats collection
877// system.
878func (w *Writer) Stats() WriterStats {
879 stats := w.stats()
880 return WriterStats{
881 Dials: stats.dials.snapshot(),
882 Writes: stats.writes.snapshot(),
883 Messages: stats.messages.snapshot(),
884 Bytes: stats.bytes.snapshot(),
885 Errors: stats.errors.snapshot(),
886 DialTime: stats.dialTime.snapshotDuration(),
887 BatchTime: stats.batchTime.snapshotDuration(),
888 BatchQueueTime: stats.batchQueueTime.snapshotDuration(),
889 WriteTime: stats.writeTime.snapshotDuration(),
890 WaitTime: stats.waitTime.snapshotDuration(),
891 Retries: stats.retries.snapshot(),
892 BatchSize: stats.batchSize.snapshot(),
893 BatchBytes: stats.batchSizeBytes.snapshot(),
894 MaxAttempts: int64(w.maxAttempts()),
895 WriteBackoffMin: w.writeBackoffMin(),
896 WriteBackoffMax: w.writeBackoffMax(),
897 MaxBatchSize: int64(w.batchSize()),
898 BatchTimeout: w.batchTimeout(),
899 ReadTimeout: w.readTimeout(),
900 WriteTimeout: w.writeTimeout(),
901 RequiredAcks: int64(w.RequiredAcks),
902 Async: w.Async,
903 Topic: w.Topic,
904 }
905}
906
907func (w *Writer) chooseTopic(msg Message) (string, error) {
908 // w.Topic and msg.Topic are mutually exclusive, meaning only 1 must be set

Callers 2

testWriterDefaultStatsFunction · 0.95

Calls 10

statsMethod · 0.95
maxAttemptsMethod · 0.95
writeBackoffMinMethod · 0.95
writeBackoffMaxMethod · 0.95
batchSizeMethod · 0.95
batchTimeoutMethod · 0.95
readTimeoutMethod · 0.95
writeTimeoutMethod · 0.95
snapshotDurationMethod · 0.80
snapshotMethod · 0.45

Tested by 2

testWriterDefaultStatsFunction · 0.76