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

OtlpHttpLogExporter does not wait for HTTP request completion, causing issues with PersistenceLogExporterDecorator #633

Open
n-ravichandran opened this issue Nov 7, 2024 · 2 comments

Comments

@n-ravichandran
Copy link

The OtlpHttpLogExporter currently does not work well when used with the PersistenceLogExporterDecorator. Specifically, the OtlpHttpLogExporter’s export function always returns success immediately, without waiting for the HTTP request to complete. This behavior results in the PersistenceLogExporterDecorator prematurely deleting the logs from the file system, thus not effectively utilizing the persistence mechanism.

Steps to Reproduce

  1. Decorate OtlpHttpLogExporter with PersistenceLogExporterDecorator.
  2. Send logs that are expected to persist until confirmed exported.
  3. Observe that logs are removed from the file system without confirmation of successful upload.

Expected Behavior

The OtlpHttpLogExporter should wait for the HTTP request to complete before returning success, allowing the PersistenceLogExporterDecorator to safely remove the batch of logs from the file system only after they are confirmed uploaded.

Actual Behavior

The OtlpHttpLogExporter immediately returns success, causing PersistenceLogExporterDecorator to delete logs prematurely, which defeats the purpose of file system persistence.

Suggested Solution

It would be beneficial for the OtlpHttpLogExporter to await the completion of the HTTP request before it returns the ExportResult. This approach would enable the PersistenceLogExporterDecorator to manage the deletion or retrying of the batch effectively.

@n-ravichandran n-ravichandran changed the title OtlpHttpLogExporter does not wait for HTTP request completion, causing issues with PersistenceLogExporterDecorator OtlpHttpLogExporter does not wait for HTTP request completion, causing issues with PersistenceLogExporterDecorator Nov 7, 2024
@bryce-b
Copy link
Member

bryce-b commented Nov 7, 2024

This seems to be an issue with all exporters.

@Westacular
Copy link

There's an additional, slightly related issue that all of the OtlpHttp*Exporter classes treat 4xx/5xx errors as 'success': The HTTPClient class that they use only returns failures if URLSession reports an error for the request... which only happens if there's a connection error; as far as URLSession is concerned, a 4xx or 5xx response is a 'success'. Something in HTTPClient should probably be checking the http status code and surfacing those as failures for the exporter classes to handle appropriately.

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

No branches or pull requests

3 participants