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] New exporter helper for custom requests #7874

Closed
wants to merge 3 commits into from

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Jun 12, 2023

Introduce a new exporter helper that operates over client-provided requests instead of pdata. The helper user now have to provide:

  • Converter: an interface with a function implementing translation of pdata Metrics/Traces/Logs into a user-defined Request.
  • Request sender: a function that will be called to send the Request

It opens a door for moving batching to the exporter, where batches will be built from client data format, instead of pdata. The batches can be properly sized by custom request size, which can be different from OTLP. The same custom request sizing will be applied to the sending queue. It will also improve performance of the sending queue retries for non-OTLP exporters, they don't need to translate pdata on every retry.

This is an experimental API. Once stabilized, it's intended to replace the existing helpers.

Tracking Issue: #8122

Related issue: #4646

@dmitryax dmitryax requested review from a team and mx-psi June 12, 2023 07:08
@dmitryax dmitryax marked this pull request as draft June 12, 2023 07:08
@dmitryax dmitryax changed the title [exporterhelper] New exporter helper with costom requests [exporterhelper] New exporter helper for custom requests Jun 12, 2023
@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Patch coverage: 83.11% and project coverage change: -0.14% ⚠️

Comparison is base (3089ea8) 90.25% compared to head (9b9cc80) 90.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7874      +/-   ##
==========================================
- Coverage   90.25%   90.11%   -0.14%     
==========================================
  Files         301      302       +1     
  Lines       15551    15709     +158     
==========================================
+ Hits        14035    14156     +121     
- Misses       1227     1258      +31     
- Partials      289      295       +6     
Files Changed Coverage Δ
exporter/exporterhelper/request.go 28.57% <28.57%> (ø)
exporter/exporterhelper/queued_retry.go 90.39% <70.96%> (-4.87%) ⬇️
exporter/exporterhelper/logs.go 83.33% <84.90%> (+2.68%) ⬆️
exporter/exporterhelper/metrics.go 83.33% <84.90%> (+2.68%) ⬆️
exporter/exporterhelper/traces.go 83.48% <84.90%> (+2.53%) ⬆️
exporter/exporterhelper/common.go 91.30% <100.00%> (+0.49%) ⬆️
...porter/exporterhelper/internal/persistent_queue.go 100.00% <100.00%> (ø)
...rter/exporterhelper/internal/persistent_storage.go 92.66% <100.00%> (+0.02%) ⬆️
...xporterhelper/internal/persistent_storage_batch.go 85.36% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dmitryax dmitryax force-pushed the exporter-v2 branch 4 times, most recently from 9d5bbe4 to 5fc2162 Compare June 30, 2023 06:27
@dmitryax dmitryax marked this pull request as ready for review June 30, 2023 06:30
Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

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

Looking forward! I see this as an important step for batching by request size.

@dmitryax
Copy link
Member Author

@open-telemetry/collector-approvers, please review whenever you have a chance. I'm planning to put more PR's on top of it next week

Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Apologies for the delay in reviewing this, I missed this

exporter/exporterhelper/common.go Show resolved Hide resolved
exporter/exporterhelper/request.go Outdated Show resolved Hide resolved
)

// Request represents a single request that can be sent to the endpoint.
type Request interface {
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this interface unimplementable and have some public base request struct to provide default implementations for future methods?

Copy link
Member

Choose a reason for hiding this comment

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

Alternative is to have also RequestItemer (or something like that) so we just don't need an interface and we use any. And ask users to provide funcs that work with the request. Another option is to ask user to implement the Send on that request as well, but right now ItemCount is on the request but Send is not, so inconsistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternative is to have also RequestItemer (or something like that) so we just don't need an interface and we use any. And ask users to provide funcs that work with the request

In that case, do you suggest we make this an optional interface? We could do that, but the new itemized queue and batching exporter helpers won't work. We can probably allow that in case clients don't need that.

Another option is to ask user to implement the Send on that request as well, but right now ItemCount is on the request but Send is not, so inconsistent.

What if we ask clients to implement Request with only one required Send function, and if they want itemized queue or batching helpers, they implement the optional interface RequestItemer. Then, we can possibly introduce bytes-sized queue or batching helpers if they implement RequestSizer.

type Request interface {
	Send(ctx context.Context) error
}

type RequestItemer interface {
	ItemsCount()  int
}

type RequestSizer interface {
	BytesSize() int
}

WDYT?

Copy link
Member Author

@dmitryax dmitryax Aug 7, 2023

Choose a reason for hiding this comment

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

I submitted another PR with the suggested approach #8178

exporter/exporterhelper/logs.go Outdated Show resolved Hide resolved
exporter/exporterhelper/logs.go Outdated Show resolved Hide resolved
exporter/exporterhelper/logs.go Outdated Show resolved Hide resolved
dmitryax added 2 commits July 29, 2023 11:30
Introduce a new exporter helper that operates over client provided requests instead of pdata. 

It opens a door for moving batching to the exporter where batches will be built from clients data format, instead of pdata. The batches can be properly sized by custom request size which can be different from OTLP. The same custom request sizing will be applied to the sending queue. It will also improve performance of the sending queue retries for non-OTLP exporters, they don't need to translate pdata on every retry. 

This is an experimental API, once stabilized it's intended to replace the existing helpers.
@jpkrohling
Copy link
Member

I would like to review this before it gets merged, especially if it conflicts with #7510.

@jpkrohling jpkrohling self-requested a review August 2, 2023 18:26
dmitryax added a commit that referenced this pull request Aug 21, 2023
Introduce a new exporter helper that operates over client-provided
requests instead of pdata. The helper user now has to provide
`Converter` - an interface with a function implementing translation of
pdata Metrics/Traces/Logs into a user-defined `Request`. `Request` is an
interface with only one required function `Export`.

It opens a door for moving batching to the exporter, where batches will
be built from client data format, instead of pdata. The batches can be
properly sized by custom request size, which can be different from OTLP.
The same custom request sizing will be applied to the sending queue. It
will also improve the performance of the sending queue retries for
non-OTLP exporters, they don't need to translate pdata on every retry.

This is an implementation alternative to
#7874 as
suggested in
#7874 (comment)

Tracking Issue:
#8122

---------

Co-authored-by: Alex Boten <alex@boten.ca>
@dmitryax
Copy link
Member Author

Superseded by #8178

@dmitryax dmitryax closed this Aug 21, 2023
@dmitryax dmitryax deleted the exporter-v2 branch August 21, 2023 23:10
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.

5 participants