Skip to content

Commit

Permalink
Update sarama to master + SASL fix (elastic#2798) (elastic#2804)
Browse files Browse the repository at this point in the history
* Update sarama to master + SASL fix

- based on v1.10.1
- master:
  - fixes bug in in v0.10 protocol if compression is enabled (default)
  - introduces broker metrics
- SASL/plain included

* Add kafka 0.10.0.1 version string to config

* Hook up sarama kafka metrics
  • Loading branch information
Steffen Siering authored and tsg committed Oct 19, 2016
1 parent 44b4b93 commit 318d834
Show file tree
Hide file tree
Showing 52 changed files with 4,630 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ https://github.com/elastic/beats/compare/v5.0.0-rc1...5.0[Check the HEAD diff]
*Affecting all Beats*

- Fix kafka output re-trying batches with too large events. {issue}2735[2735]
- Fix kafka output protocol error if `version: 0.10` is configured. {issue}2651[2651]
- Fix kafka output connection closed by broker on SASL/PLAIN. {issue}2717[2717]

*Metricbeat*

Expand Down
5 changes: 4 additions & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ import:
- package: github.com/miekg/dns
version: 5d001d020961ae1c184f9f8152fdc73810481677
- package: github.com/Shopify/sarama
version: v1.10.0
version: fix/sasl-handshake
repo: https://github.com/urso/sarama
- package: github.com/rcrowley/go-metrics
version: ab2277b1c5d15c3cba104e9cbddbdfc622df5ad8
- package: github.com/klauspost/crc32
version: v1.0
- package: github.com/golang/snappy
Expand Down
24 changes: 22 additions & 2 deletions libbeat/outputs/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"errors"
"fmt"
"strings"
"sync"
"time"

"github.com/Shopify/sarama"
metrics "github.com/rcrowley/go-metrics"
"github.com/rcrowley/go-metrics/exp"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/op"
Expand Down Expand Up @@ -35,11 +38,26 @@ const (
defaultMaxWaitRetry = 60 * time.Second
)

var kafkaMetricsRegistryInstance metrics.Registry

func init() {
sarama.Logger = kafkaLogger{}

reg := metrics.NewPrefixedRegistry("libbeat.kafka.")

// Note: registers /debug/metrics handler for displaying all expvar counters
exp.Exp(reg)
kafkaMetricsRegistryInstance = reg

outputs.RegisterOutputPlugin("kafka", New)
}

var kafkaMetricsOnce sync.Once

func kafkaMetricsRegistry() metrics.Registry {
return kafkaMetricsRegistryInstance
}

var debugf = logp.MakeDebug("kafka")

var (
Expand Down Expand Up @@ -71,8 +89,9 @@ var (
"0.9": sarama.V0_9_0_1,

"0.10.0.0": sarama.V0_10_0_0,
"0.10.0": sarama.V0_10_0_0,
"0.10": sarama.V0_10_0_0,
"0.10.0.1": sarama.V0_10_0_1,
"0.10.0": sarama.V0_10_0_1,
"0.10": sarama.V0_10_0_1,
}
)

Expand Down Expand Up @@ -313,5 +332,6 @@ func newKafkaConfig(config *kafkaConfig) (*sarama.Config, error) {
}
k.Version = version

k.MetricRegistry = kafkaMetricsRegistry()
return k, nil
}
1 change: 1 addition & 0 deletions vendor/github.com/Shopify/sarama/.github/ISSUE_TEMPLATE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/Shopify/sarama/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 133 additions & 5 deletions vendor/github.com/Shopify/sarama/broker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Shopify/sarama/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/github.com/Shopify/sarama/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 318d834

Please sign in to comment.