open-telemetry / opentelemetry-swift

OpenTelemetry API for Swift
https://opentelemetry.io/docs/instrumentation/swift/
Apache License 2.0
222 stars 146 forks source link

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

Open n-ravichandran opened 2 days ago

n-ravichandran commented 2 days ago

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.

bryce-b commented 2 days ago

This seems to be an issue with all exporters.