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

[exporter/kafkaexporter] ExporterFactory log/metric marshaler options #13433

Closed
wants to merge 12 commits into from
Closed

[exporter/kafkaexporter] ExporterFactory log/metric marshaler options #13433

wants to merge 12 commits into from

Conversation

bgranetzke
Copy link
Contributor

@bgranetzke bgranetzke commented Aug 19, 2022

[exporter/kafkaexporter] ExporterFactory log/metric marshaler options

Description:
Adding ExportFactory options to add custom log/metric marshalers (similar to existing: WithTracesMarshalers)

This is a reboot of this PR. It eventually went stale and closed. The outstanding issue was related to improving the existing test for WithTracesMarshalers and adding similar to the new options. After struggling with struct/func visibility constraints, I ended up adding yet another FactoryOption which allowed me to inject a mock sarama.SyncProducer to verify the messages produced by the configured marshaler. The change to support the test was much more invasive than I expected and am open to alternatives.

There are also other related PRs which also went stale that I think could benefit from the new options:
#8336
#8272

Adding WithMetricsMarshalers/WithLogMarshalers options to parallel WithTracesMarshalers
@bgranetzke bgranetzke requested review from a team and djaglowski August 19, 2022 13:52
@TylerHelmuth
Copy link
Member

pinging @pavolloffay @MovieStoreGuy as code owners

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Sep 21, 2022
@bgranetzke
Copy link
Contributor Author

@MovieStoreGuy What do we want to do here? I'd prefer not to fork just go get these factory options.

@MovieStoreGuy
Copy link
Contributor

@bgranetzke is there an open issue for this change?

@bgranetzke
Copy link
Contributor Author

@MovieStoreGuy No, I don't see an open issue for this specifically, however, the capability to add custom marshalers would empower these features to progress without forking:

open
#13252
#12621
#12318
#7416
#5847

closed-no solution
#6126

There are also the three PRs mentioned in the description.

I can create a new issue if you would like.

Copy link
Contributor

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

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

I am sorry but I am not convinced on the design at present.

The concern I have here is embedding the SaramaProducer function as part of the kafkaExporterFactory struct would result in nil reference if not correctly set.
I am also unsure how this would improve user's usage of the exporter.

If you can raise an issue to discuss the design you're intending to achieve, I would be more than happy to spare on that with you.

unreleased/kafkaexporter-additional-factory-options.yaml Outdated Show resolved Hide resolved
exporter/kafkaexporter/factory.go Outdated Show resolved Hide resolved
@@ -107,10 +132,13 @@ func createDefaultConfig() config.Exporter {
}
}

type ProducerFactoryFunc func(config Config) (sarama.SyncProducer, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment exported types for their intended use.

Comment on lines +83 to +89
// WithProducerFactory sets an alternative producer factory.
func WithProducerFactory(producerFactory ProducerFactoryFunc) FactoryOption {
return func(factory *kafkaExporterFactory) {
factory.producerFactory = producerFactory
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you expand upon why you would need an alternative producer factory, it isn't clear to me why you would need this and why you'd want to use this.

Copy link
Contributor Author

@bgranetzke bgranetzke Sep 26, 2022

Choose a reason for hiding this comment

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

It was only to test the custom marshaler option. I did not like it either, but due to how the actual factory is wrapped inside the component.ExporterFactory, I had to inject the mock during NewFactory(). I didn't want to create kafkaExporterFactory directly because then if felt like I wasn't testing the new options I was adding.

Totally open to an alternative approach.

exporter/kafkaexporter/marshaler_test.go Show resolved Hide resolved
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Oct 13, 2022
@github-actions github-actions bot removed the Stale label Oct 24, 2022
@bgranetzke
Copy link
Contributor Author

Closing as this PR is replaced by #16540

@bgranetzke bgranetzke closed this Dec 1, 2022
@bgranetzke bgranetzke deleted the exporter/kafkaexporter_marshaler_options branch December 1, 2022 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants