Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/pipeline/encode/encode_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func NewEncodeKafka(params config.StageParam) (Encoder, error) {
WriteTimeout: time.Duration(writeTimeoutSecs) * time.Second,
BatchSize: jsonEncodeKafka.BatchSize,
BatchBytes: jsonEncodeKafka.BatchBytes,
// Temporary fix may be we should implement a batching systems
// https://github.com/segmentio/kafka-go/issues/326#issuecomment-519375403
BatchTimeout: time.Nanosecond,
}

return &encodeKafka{
Expand Down
15 changes: 13 additions & 2 deletions pkg/pipeline/ingest/ingest_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (w *TransportWrapper) Send(_, data []byte) error {
message := goflowpb.FlowMessage{}
err := proto.Unmarshal(data, &message)
if err != nil {
// temporary fix
// A PR was submitted to log this error from goflow2:
// https://github.com/netsampler/goflow2/pull/86
log.Error(err)
return err
}
renderedMsg, err := RenderMessage(&message)
Expand Down Expand Up @@ -171,7 +175,7 @@ func (ingestC *ingestCollector) processLogLines(out chan<- []interface{}) {
recordAsBytes, _ := json.Marshal(record)
records = append(records, string(recordAsBytes))
if len(records) >= ingestC.batchMaxLength {
log.Debugf("ingestCollector sending %d entries", len(records))
log.Debugf("ingestCollector sending %d entries, %d entries waiting", len(records), len(ingestC.in))
linesProcessed.Add(float64(len(records)))
queueLength.Set(float64(len(out)))
out <- records
Expand All @@ -180,7 +184,14 @@ func (ingestC *ingestCollector) processLogLines(out chan<- []interface{}) {
case <-flushRecords.C:
// Process batch of records (if not empty)
if len(records) > 0 {
log.Debugf("ingestCollector sending %d entries", len(records))
if len(ingestC.in) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix is here, if the out channel is full, then we only loop once or twice in the ingest case before looping again in this case.

for len(records) < ingestC.batchMaxLength && len(ingestC.in) > 0 {
record := <-ingestC.in
recordAsBytes, _ := json.Marshal(record)
records = append(records, string(recordAsBytes))
}
}
log.Debugf("ingestCollector sending %d entries, %d entries waiting", len(records), len(ingestC.in))
linesProcessed.Add(float64(len(records)))
queueLength.Set(float64(len(out)))
out <- records
Expand Down