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

[exporterhelper] Refactor options and baseExporter #8369

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Sep 6, 2023

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.

@dmitryax dmitryax force-pushed the refactor-exporter-sender branch 3 times, most recently from 7f46194 to 44c8eae Compare September 7, 2023 19:13
@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Patch coverage is 97.29% of modified lines.

Files Changed Coverage
exporter/exporterhelper/common.go 95.29%
exporter/exporterhelper/logs.go 100.00%
exporter/exporterhelper/metrics.go 100.00%
exporter/exporterhelper/queued_retry.go 100.00%
exporter/exporterhelper/traces.go 100.00%

📢 Thoughts on this report? Let us know!.

@dmitryax dmitryax added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 7, 2023
@dmitryax dmitryax force-pushed the refactor-exporter-sender branch 2 times, most recently from 096111c to 7c5b10d Compare September 7, 2023 19:51
@dmitryax dmitryax changed the title [DRAFT] [exporterhelper] Refactor options and baseExporter [chore] [exporterhelper] Refactor options and baseExporter Sep 7, 2023
@dmitryax dmitryax marked this pull request as ready for review September 7, 2023 19:52
@dmitryax dmitryax requested review from a team and codeboten September 7, 2023 19:52
// Option apply changes to baseSettings.
type Option func(*baseSettings)
type Option func(*baseExporter)
Copy link
Member Author

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

Copy link
Member

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.

@dmitryax dmitryax force-pushed the refactor-exporter-sender branch 6 times, most recently from 73cbd59 to 2c33fb1 Compare September 7, 2023 21:13
@dmitryax dmitryax removed the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 7, 2023
@dmitryax dmitryax changed the title [chore] [exporterhelper] Refactor options and baseExporter [exporterhelper] Refactor options and baseExporter Sep 7, 2023
// Option apply changes to baseSettings.
type Option func(*baseSettings)
type Option func(*baseExporter)
Copy link
Member

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.

Comment on lines 235 to 241
// 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()
Copy link
Member

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?

Copy link
Member Author

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 {
Copy link
Member

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.

Copy link
Member Author

@dmitryax dmitryax Sep 8, 2023

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

Copy link
Contributor

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 :)

exporter/exporterhelper/common.go Outdated Show resolved Hide resolved
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.
@dmitryax dmitryax merged commit 4e71dc1 into open-telemetry:main Sep 8, 2023
30 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 8, 2023
@dmitryax dmitryax deleted the refactor-exporter-sender branch September 11, 2023 00:37
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