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] Add queue options to the new exporter helper #8248

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Aug 18, 2023

This change enabled queue capability for the new exporter helper. For now, it preserves the same user configuration interface as the existing exporter helper has. The only difference is that implementing persistence is optional now as it requires providing marshal and unmarshal functions for the custom request.

Later, it's possible to introduce more options for controlling the queue: count of items or bytes in the queue.

Tracking issue: #8122

@dmitryax dmitryax requested review from a team and jpkrohling August 18, 2023 06:23
@codecov
Copy link

codecov bot commented Aug 18, 2023

Codecov Report

Patch coverage is 100.00% of modified lines.

Files Changed Coverage
exporter/exporterhelper/request.go ø
exporter/exporterhelper/common.go 100.00%
exporter/exporterhelper/queue_sender.go 100.00%

📢 Thoughts on this report? Let us know!.

@dmitryax dmitryax force-pushed the exporterhelper-v2-enable-queue-retry branch 2 times, most recently from 0589798 to bf50039 Compare August 21, 2023 19:46
@dmitryax dmitryax added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Aug 21, 2023
@dmitryax dmitryax force-pushed the exporterhelper-v2-enable-queue-retry branch 2 times, most recently from cd900e4 to b8af2fb Compare August 21, 2023 22:25
.chloggen/exporter-helper-v2.yaml Outdated Show resolved Hide resolved
Comment on lines 150 to 152
// WithMemoryQueue overrides the default QueueConfig for an exporter to use an in-memory queue.
func WithMemoryQueue(config QueueConfig) Option {
return func(o *baseSettings) {
o.queueSettings.config = QueueSettings{
Enabled: config.Enabled,
NumConsumers: config.NumConsumers,
QueueSize: config.QueueSize,
}
}
}

// WithPersistentQueue overrides the default QueueConfig for an exporter to use a persistent queue.
// This option can be used only with the new exporter helpers New[Traces|Metrics|Logs]RequestExporter.
func WithPersistentQueue(config PersistentQueueConfig, marshaler RequestMarshaler, unmarshaler RequestUnmarshaler) Option {
Copy link
Member

Choose a reason for hiding this comment

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

To avoid possible miss-usage of these APIs by having users configuring both queues, should we have an API that avoids that? Something like this (not necessary this way, but the idea like this):

func WithQueue(config *QueueConfig) Option

type QueueConfig struct {
  ...
}

func NewMemoryQueueConfig(...) QueueConfig

func NewPersistentQueueConfig(...) QueueConfig

Copy link
Member

Choose a reason for hiding this comment

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

Or func WithQueue(config *QueueOption) Option

Copy link
Member

Choose a reason for hiding this comment

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

Alternative for even more generic, you have func WithQueue(queue Queue) Option, where Queue is the current ProducerConsumerQueue. This way we can have the queue implementation outside of this package.

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 like func WithQueue(queue Queue) Option. It makes future improvements/additions to the queues easier. But it requires some refactoring because the persistent queue is initialized in two steps currently. I'm trying this out. It has to be refactored anyway I believe

Copy link
Member Author

Choose a reason for hiding this comment

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

@bogdandrutu I submitted a draft PR with the refactoring allowing the WithQueue option #8275. PTAL once you have a chance

Copy link
Member Author

Choose a reason for hiding this comment

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

@bogdandrutu, following the discussion in #8284 (comment), I'm now more inclined towards this PR other than #8275 due to the following reasons:

  • Exposing Queue interface with the Start method is fine, but Callback and other arguments outlined in [chore] [exporterhelper] Refactor queue initialization #8284 (comment) cannot be part of the constructors exposed to the users. So, if we don't want them passed as Start arguments, we need to encapsulate the internal Queue and hide these arguments. Probably it'll look more like another option that you suggesdted func WithQueue(config *QueueOption) Option

  • Using the interface from this PR seems like requires the least amount of code to write for the user.

Do you think WithQueue is also better in case we might want to introduce another type of Queue in future?

Copy link
Member

Choose a reason for hiding this comment

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

The big downside for this is that this package must depend on the queue implementations so if we need to extend in the future we need to grow this package and its dependencies (if extension needs for example S3 queue). Maybe directly Queue is hard to expose, but we can have WithQueue(factory QueueFactory) where the factory gets the Callback as part of the initialization settings.

Copy link
Member Author

Choose a reason for hiding this comment

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

@bogdandrutu I see your point. I took your recommendations from this thread and #8435 into account and implemented #8275. I had to introduce a few more packages to avoid circular dependencies. PTAL and let me know if that is close to how you envision it.

This change enabled queue capability for the new exporter helper. For now, it preserves the same user configuration interface as the existing exporter helper has. The only difference is that implementing persistence is optional now as it requires providing marshal and unmarshal functions for the custom request.

Later, it's possible to introduce more options for controlling the queue: count of items or bytes in the queue.
@dmitryax dmitryax force-pushed the exporterhelper-v2-enable-queue-retry branch from cb206be to cf07b8f Compare September 13, 2023 21:27
@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 30, 2023
@dmitryax dmitryax removed the Stale label Sep 30, 2023
@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 17, 2023
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Oct 31, 2023
bogdandrutu pushed a commit that referenced this pull request Feb 3, 2024
Introduce a way to enable queue in the new exporter helper with a
developer interface suggested in
#8248 (comment).

The new configuration interface for the end users provides a new
`queue_size_items` option to limit the queue by a number of spans, log
records, or metric data points. The previous way to limit the queue by
number of requests is preserved under the same field, `queue_size,`
which will later be deprecated through a longer transition process.

Tracking issue:
#8122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants