-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[exporterhelper] Refactor options and baseExporter #8369
[exporterhelper] Refactor options and baseExporter #8369
Conversation
7f46194
to
44c8eae
Compare
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
44c8eae
to
672af7e
Compare
096111c
to
7c5b10d
Compare
// Option apply changes to baseSettings. | ||
type Option func(*baseSettings) | ||
type Option func(*baseExporter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this signature should not be considered a breaking change since the argument is of unexported type, so users cannot implement it directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would suggest in a separate PR to change this to an interface with a private func. I think this is kind of the recommended new way of doing options.
73cbd59
to
2c33fb1
Compare
2c33fb1
to
28bc997
Compare
// Option apply changes to baseSettings. | ||
type Option func(*baseSettings) | ||
type Option func(*baseExporter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would suggest in a separate PR to change this to an interface with a private func. I think this is kind of the recommended new way of doing options.
exporter/exporterhelper/common.go
Outdated
// If no error then start the queueSender. | ||
return be.queueSender.start(ctx, host, be.set) | ||
} | ||
|
||
func (be *baseExporter) Shutdown(ctx context.Context) error { | ||
// First shutdown the retry sender | ||
be.retrySender.shutdown() | ||
|
||
// Then shutdown the queue sender | ||
be.queueSender.shutdown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random senders that you start/stop. If the interface is like that, you should call start on all. Also should it call start on the next sender itself and same for stop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shutdown sequence is a bit random for a reason. Ideally, it could've been the same sequence as in the pipelines, the same as the data flow: queueSender -> retrySender -> user's exporter. But we need to stop the retrySender
first so it can push an unfinished request back to the queue.
The start sequence should be applied in reverse order.
@@ -213,3 +271,22 @@ func (ts *timeoutSender) send(req internal.Request) error { | |||
} | |||
return req.Export(ctx) | |||
} | |||
|
|||
func createSampledLogger(logger *zap.Logger) *zap.Logger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to revisit this, seems very arbitrary to have a sampler logger only for some cases. Maybe just better document as comment of the func why we have this and where should be used, but it is still random for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. We have another effort to address this #8134. I'm just moving it from one file to another as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @dmitryax ,
Right as part of #8134 we want to have a Sampled logger as part of the TelemetrySetting and use it when needed.
Please @bogdandrutu @dmitryax take a look at my PR #8134. Thanks :)
28bc997
to
c5c1e7c
Compare
Separate all the parts of the baseExporter into an explicit chain of request senders. It makes it easier to follow the data flow and add additional senders. This change also removes the baseSettings, because it's not needed to keep the settings anymore. All the options are now applied on the baseExporter and update the internal senders in place.
c5c1e7c
to
224eb93
Compare
Separate all the parts of the baseExporter into an explicit chain of request senders. It makes it easier to follow the data flow and add additional senders.
This change also removes the baseSettings, because keeping the settings is not needed anymore. All the options update the internal senders in place.
This change also removes confusing error messages like "Exporting failed. Dropping data. Try enabling sending_queue to survive temporary failures" when the Queue is not even available in the exporter (WithQueue option is not applied) which means users don't
sending_queue
config option. Now, such messages are only shown when the sending_queue (or retry_on_failure) is available, but not enabled by the user.