File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -108,11 +108,24 @@ In order to read data, we can iterate through our signal storage objects and the
108108a network exporter, as shown in the example for spans below.
109109
110110``` java
111- // Example of reading an exporting spans from disk
112- OtlpHttpSpanExporter networkExporter;
113- Iterator<Collection<SpanData > > spanCollections = spanStorage. iterator();
114- while (spanCollections. hasNext()){
115- networkExporter. export(spanCollections. next());
111+ /**
112+ * Example of reading and exporting spans from disk.
113+ *
114+ * @return true, if the exporting was successful, false, if it needs to be retried
115+ */
116+ public boolean exportSpansFromDisk(SpanExporter networkExporter, long timeout) {
117+ for (Collection<SpanData > spanData : spanStorage) {
118+ CompletableResultCode resultCode = networkExporter. export(spanData);
119+ resultCode. join(timeout, TimeUnit . MILLISECONDS );
120+
121+ if (! resultCode. isSuccess()) {
122+ logger. trace(" Error while exporting" , resultCode. getFailureThrowable());
123+ // The iteration should be aborted here to avoid consuming batches, which were not exported successfully
124+ return false ;
125+ }
126+ }
127+ logger. trace(" Finished exporting" );
128+ return true ;
116129}
117130```
118131
You can’t perform that action at this time.
0 commit comments