-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Otlp Trace Exporters to Event Exporter #70
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
Conversation
It puts failed items in the failedItems and try them until network is restored
…factor * andrey/offline-stability: switch stg fix probable crash BatchWorker without MultiExporter # Conflicts: # Sources/Observability/Transport/BatchWorker.swift # Sources/Observability/Transport/EventQueue.swift
* main: chore(main): release 0.9.0 (#68) fix: Make Session Replay stable for offline or intermittent network (#67) feat: cold, warm and hot launch times meter (#66) # Conflicts: # Sources/Observability/Logs/LogItem.swift # Sources/Observability/Transport/BatchWorker.swift # Sources/Observability/Transport/EventQueue.swift
| let decorator = TracerDecorator(options: options, sessionManager: sessionManager, exporter: tracesExporter) | ||
| Task { | ||
| await batchWorker.addExporter(traceEventExporter) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Asynchronous Exporter Registration Causes Lost Traces Metrics Logs
Race condition: The trace exporter is added to batchWorker in a fire-and-forget Task, but execution continues immediately without waiting. This means traces could be generated and sent to the eventQueue before the exporter is registered with batchWorker, causing those traces to be lost or not exported properly. The same issue exists for metrics (lines 123-125) and logs (lines 54-56). The Task should be awaited or the exporter should be added synchronously before the TracerDecorator is created and used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good. It will be just in buffer for this time.
* main: chore: refactor metrics to event exporter (#69) # Conflicts: # Sources/Observability/Metrics/OtlpMetricEventExporter.swift # Sources/Observability/Metrics/OtlpMetricScheduleExporter.swift # TestApp/Sources/AppDelegate.swift
| extension TracerDecorator { | ||
| func startSpan(name: String, attributes: [String : AttributeValue], startTime: Date = Date()) -> any Span { | ||
| let builder = tracer.spanBuilder(spanName: name) | ||
| extension Tracer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Flush() Fails to Export Pending Spans
The flush() method now returns true without actually flushing any data. The previous implementation called spanProcessor.forceFlush(timeout: 5.0) to ensure spans were exported. With the new event queue architecture, the flush() method should trigger flushing of the eventQueue or batchWorker to ensure pending spans are exported, but it currently does nothing. This could lead to data loss if callers rely on flush() to ensure spans are exported before shutdown or other critical operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just server requirement from protocol and doesn't needed for mobile
| Observability.OtlpTraceEventExporter.self | ||
| } | ||
|
|
||
| let spanData: SpanData |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private ? understanding that all coming from EventQueueItemPayload could be internal, but why spanData is internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need read spanData in exporter. SpanData is what Protobuf exporter uses
🤖 I have created a release *beep* *boop* --- ## [0.9.1](0.9.0...0.9.1) (2025-11-05) ### Bug Fixes * Otlp Trace Exporters to Event Exporter ([#70](#70)) ([cfa92fb](cfa92fb)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Bumps version to 0.9.1 and updates CHANGELOG with a bug fix for OTLP Trace Exporters to Event Exporter. > > - **Release 0.9.1**: > - Update `Sources/LaunchDarklyObservability/Version.swift` `sdkVersion` to `0.9.1`. > - Update `.release-please-manifest.json` to `0.9.1`. > - Add `CHANGELOG.md` entry noting bug fix: OTLP Trace Exporters to Event Exporter. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d383ddb. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
* main: chore(main): release 0.9.1 (#71) fix: Otlp Trace Exporters to Event Exporter (#70) chore: refactor metrics to event exporter (#69) # Conflicts: # Sources/Observability/Metrics/OtlpMetricEventExporter.swift # Sources/Observability/Metrics/OtlpMetricScheduleExporter.swift # Sources/Observability/Traces/EventSpanProcessor.swift # Sources/Observability/Traces/OtlpTraceEventExporter.swift # Sources/Observability/Traces/SpanItem.swift # TestApp/Sources/AppDelegate.swift
* main: chore(main): release 0.9.2 (#73) fix: user snap tap (#72) chore(main): release 0.9.1 (#71) fix: Otlp Trace Exporters to Event Exporter (#70) chore: refactor metrics to event exporter (#69) # Conflicts: # Sources/Observability/Client/ObservabilityClientFactory.swift # Sources/Observability/Metrics/OtlpMetricEventExporter.swift # Sources/Observability/Metrics/OtlpMetricScheduleExporter.swift # Sources/Observability/Traces/EventSpanProcessor.swift # Sources/Observability/Traces/OtlpTraceEventExporter.swift # Sources/Observability/Traces/SpanItem.swift # Sources/Observability/Traces/TracerDecorator.swift # Sources/Observability/UIInteractions/UInteraction+Span.swift # TestApp/Sources/AppDelegate.swift
Move Traces to LD buffering
Proof of testing:

Note
Route trace exporting through the LD event queue with a new OTLP trace event exporter and processor, removing legacy sampling/stdout exporters.
EventSpanProcessor,OtlpTraceEventExporter, andSpanItem.TracerDecoratorto use sampler +EventQueue(removesBatchSpanProcessor/directSpanExporterusage) and provide start-with-time helper viaTracerextension.ObservabilityClientFactoryviaBatchWorker.SamplingTraceExporter.swift,SamplingLogExporter.swift,LDStdoutExporter.swift.OtlpMetricEventExporterandOtlpMetricScheduleExporterinternal and encapsulate properties (no functional change)..urlSessioninautoInstrumentationconfig.Written by Cursor Bugbot for commit 14ec46a. This will update automatically on new commits. Configure here.