Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kafka exporter #1439

Merged
merged 11 commits into from
Jul 29, 2020
Merged

Conversation

pavolloffay
Copy link
Member

Signed-off-by: Pavol Loffay ploffay@redhat.com

Description:

Notable changes

Link to tracking Issue:

Created from #1410 (comment)

Resolves open-telemetry/opentelemetry-collector-contrib#268
Related to #1331

Testing: < Describe what testing was performed and which tests were added.>

Tested locally with Confluent 5.0.0 https://docs.confluent.io/5.0.0/installation/docker/docs/installation/single-node-client.html and #1410

Documentation: < Describe the documentation added.>

Added Kafka exporter readme

@codecov
Copy link

codecov bot commented Jul 27, 2020

Codecov Report

Merging #1439 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1439      +/-   ##
==========================================
+ Coverage   90.83%   90.88%   +0.05%     
==========================================
  Files         234      237       +3     
  Lines       16472    16541      +69     
==========================================
+ Hits        14962    15033      +71     
+ Misses       1082     1080       -2     
  Partials      428      428              
Impacted Files Coverage Δ
exporter/kafkaexporter/factory.go 100.00% <100.00%> (ø)
exporter/kafkaexporter/kafka_exporter.go 100.00% <100.00%> (ø)
exporter/kafkaexporter/marshaller.go 100.00% <100.00%> (ø)
service/defaultcomponents/defaults.go 84.31% <100.00%> (+0.31%) ⬆️
translator/internaldata/resource_to_oc.go 83.72% <0.00%> (ø)
consumer/consumererror/permanenterror.go 100.00% <0.00%> (+22.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39521ed...160c9cd. Read the comment docs.

type Config struct {
configmodels.ExporterSettings `mapstructure:",squash"`
// The list of kafka brokers (default localhost:9092)
Brokers []string `mapstructure:"brokers"`
Copy link
Member

Choose a reason for hiding this comment

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

Is this required to be a list? what is the behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

Kafka client accepts a list of brokers not only a single address. In statically configured environments this can be handy.

It is the initial list of broker addresses that is used to discover all nodes https://docs.confluent.io/current/installation/configuration/consumer-configs.html#bootstrap.servers

exporter/kafkaexporter/config_test.go Outdated Show resolved Hide resolved
exporter/kafkaexporter/factory.go Outdated Show resolved Hide resolved
exporter/kafkaexporter/kafka_exporter.go Show resolved Hide resolved
exporter/kafkaexporter/kafka_exporter.go Outdated Show resolved Hide resolved
exporter/kafkaexporter/kafka_exporter.go Outdated Show resolved Hide resolved
}
c.Version = version
}
producer, err := sarama.NewAsyncProducer(config.Brokers, c)
Copy link
Member

Choose a reason for hiding this comment

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

Why async producer vs sync? I would suggest to use sync producer and rely on the queued/retry logic from the exporterhelper if possible.

It is good to have a consistent logic of sending queues and retries across exporters.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree on the consistent logic across exporter. We did the same approach in the ES exporter. However this might be suboptimal for a couple of reasons:

  • multiple serializations if retry happens
  • driver can immediately retry some failed requests

Copy link
Member Author

Choose a reason for hiding this comment

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

I have switched to sync producer for now. We can switch to async if we prove that it performs better it is just an impl detail.

exporter/kafkaexporter/kafka_exporter.go Outdated Show resolved Hide resolved
@bogdandrutu
Copy link
Member

bogdandrutu commented Jul 27, 2020

Some high-level concerns/questions:

  • Using of the async processor
  • Sending individual ResourceSpan instead of the entire pdata.Traces as ExportTraceServiceRequest
	request := &otlptrace.ExportTraceServiceRequest{
		ResourceSpans: pdata.TracesToOtlp(td),
	}

@pavolloffay pavolloffay force-pushed the kafka-exporter branch 3 times, most recently from 437dc0a to d5c4ece Compare July 28, 2020 08:14
@pavolloffay
Copy link
Member Author

qretry test failed.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay
Copy link
Member Author

@bogdandrutu I have updated the PR it's ready for the second pass.

Comment on lines 55 to 63
// Retry defines retry configuration for Metadata.
type Retry struct {
// The total number of times to retry a metadata request when the
// cluster is in the middle of a leader election or at startup (default 3).
Max int `mapstructure:"max"`
// How long to wait for leader election to occur before retrying
// (default 250ms). Similar to the JVM's `retry.backoff.ms`.
BackOff time.Duration `mapstructure:"backoff"`
}
Copy link
Member

Choose a reason for hiding this comment

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

use RetrySettings from exporter helper.

Copy link
Member Author

Choose a reason for hiding this comment

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

This configuration is not for retrying failed batches to the broker.

This struct configures retries for getting the metadata from the broker. This happens at the startup or when the broker is in the middle of the leader election. This setting is useful when there is race condition at broker and producer startup e.g .in docker compose deployment.

Copy link
Member Author

Choose a reason for hiding this comment

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

also exporterhelper.RetrySettings does not define maximum number of retries [int] and it also exposes other settings that does not apply to Kafka metadata retry.

Comment on lines 44 to 46
c.Metadata.Full = config.Metadata.Full
c.Metadata.Retry.Max = config.Metadata.Retry.Max
c.Metadata.Retry.Backoff = config.Metadata.Retry.BackOff
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with other protocols, I would suggest to use this https://github.com/open-telemetry/opentelemetry-collector/blob/master/exporter/exporterhelper/queued_retry.go logic to control queuing and retry and disable native retries from the sarama client.

Copy link
Member Author

Choose a reason for hiding this comment

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

See my comment above #1439 (comment)

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

I think overall is very close to be done.

Kafka exporter exports traces to Kafka.

The following settings are required:
- `protocol_version` (no default): Kafka protocol version e.g. 2.0.0
Copy link
Member

Choose a reason for hiding this comment

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

Please mention in the readme what is the proto that we write to the queue.

Copy link
Member Author

Choose a reason for hiding this comment

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

There will be a follow-up PR to make that configurable.

Since we already import Jaeger and Zipkin we should make the encoding configurable. This will allow folks easy migration.

@bogdandrutu bogdandrutu self-assigned this Jul 28, 2020
@bogdandrutu
Copy link
Member

@pavolloffay there are few other comments not addressed. Please fix that and we are good to go.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay
Copy link
Member Author

@bogdandrutu I have addressed the comments and added more docs especially explaining that metadata retry is not the retry for failed messages.

@bogdandrutu
Copy link
Member

@pavolloffay will merge and I will do some cleanups.

Collector automation moved this from In progress to Reviewer approved Jul 29, 2020
@bogdandrutu bogdandrutu merged commit 1d31f0f into open-telemetry:master Jul 29, 2020
Collector automation moved this from Reviewer approved to Done Jul 29, 2020
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
…y#1439)

Bumps [boto3](https://github.com/boto/boto3) from 1.21.33 to 1.21.34.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](boto/boto3@1.21.33...1.21.34)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Collector
  
Done
Development

Successfully merging this pull request may close these issues.

Add kafka exporter
2 participants