diff --git a/disk-buffering/README.md b/disk-buffering/README.md index d4a5443b9..1809231ff 100644 --- a/disk-buffering/README.md +++ b/disk-buffering/README.md @@ -55,7 +55,7 @@ Each wrapper will need the following when instantiating them: * A File instance of the root directory where all the data is going to be written. The same root dir can be used for all the wrappers, since each will create their own folder inside it. * An instance - of [StorageConfiguration](src/main/java/io/opentelemetry/contrib/disk/buffering/internal/StorageConfiguration.java) + of [StorageConfiguration](src/main/java/io/opentelemetry/contrib/disk/buffering/StorageConfiguration.java) with the desired parameters. You can create one with default values by calling `StorageConfiguration.getDefault()`. @@ -64,16 +64,21 @@ take care of always storing the data it receives. #### Set up example for spans +### Writing data + +The data is written in the disk by "ToDisk" exporters, these are exporters that serialize and store the data as received by their processors. If for some reason +the "ToDisk" cannot store data in the disk, they'll delegate the data to their wrapped exporter. + ```java // Creating the SpanExporter of our choice. SpanExporter mySpanExporter = OtlpGrpcSpanExporter.getDefault(); -// Wrapping our exporter with its disk exporter. -SpanDiskExporter diskExporter = SpanDiskExporter.create(mySpanExporter, new File("/my/signals/cache/dir"), StorageConfiguration.getDefault()); +// Wrapping our exporter with its "ToDisk" exporter. +SpanToDiskExporter toDiskExporter = SpanToDiskExporter.create(mySpanExporter, StorageConfiguration.getDefault(new File("/my/signals/cache/dir"))); // Registering the disk exporter within our OpenTelemetry instance. SdkTracerProvider myTraceProvider = SdkTracerProvider.builder() - .addSpanProcessor(SimpleSpanProcessor.create(diskExporter)) + .addSpanProcessor(SimpleSpanProcessor.create(toDiskExporter)) .build(); OpenTelemetrySdk.builder() .setTracerProvider(myTraceProvider) @@ -83,12 +88,13 @@ OpenTelemetrySdk.builder() ### Reading data -Each of the exporter wrappers can read from the disk and send the retrieved data over to their -wrapped exporter by calling this method from them: +In order to read data, we need to create "FromDisk" exporters, which read data from the disk, parse it and delegate it +to their wrapped exporters. ```java try { - if(diskExporter.exportStoredBatch(1, TimeUnit.SECONDS)) { + SpanFromDiskExporter fromDiskExporter = SpanFromDiskExporter.create(memorySpanExporter, storageConfig); + if(fromDiskExporter.exportStoredBatch(1, TimeUnit.SECONDS)) { // A batch was successfully exported and removed from disk. You can call this method for as long as it keeps returning true. } else { // Either there was no data in the disk or the wrapped exporter returned CompletableResultCode.ofFailure(). diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordFromDiskExporter.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordFromDiskExporter.java index f0e1f8b52..d7940cab5 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordFromDiskExporter.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordFromDiskExporter.java @@ -5,7 +5,6 @@ package io.opentelemetry.contrib.disk.buffering; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporter; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporterImpl; import io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.SignalDeserializer; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordToDiskExporter.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordToDiskExporter.java index 48b4c4a53..3f5b894b4 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordToDiskExporter.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordToDiskExporter.java @@ -5,7 +5,6 @@ package io.opentelemetry.contrib.disk.buffering; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.ToDiskExporter; import io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers.SignalSerializer; import io.opentelemetry.sdk.common.CompletableResultCode; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricFromDiskExporter.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricFromDiskExporter.java index 9af07e8b1..bc44c2d18 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricFromDiskExporter.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricFromDiskExporter.java @@ -5,7 +5,6 @@ package io.opentelemetry.contrib.disk.buffering; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporter; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporterImpl; import io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.SignalDeserializer; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricToDiskExporter.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricToDiskExporter.java index 6620a3346..d950b035c 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricToDiskExporter.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/MetricToDiskExporter.java @@ -5,7 +5,6 @@ package io.opentelemetry.contrib.disk.buffering; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.ToDiskExporter; import io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers.SignalSerializer; import io.opentelemetry.sdk.common.CompletableResultCode; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporter.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporter.java index 2132ec911..a15d4fe31 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporter.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporter.java @@ -5,7 +5,6 @@ package io.opentelemetry.contrib.disk.buffering; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporter; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporterImpl; import io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.SignalDeserializer; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanToDiskExporter.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanToDiskExporter.java index bb1a2bb01..0d4fac3f1 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanToDiskExporter.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/SpanToDiskExporter.java @@ -5,7 +5,6 @@ package io.opentelemetry.contrib.disk.buffering; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.ToDiskExporter; import io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers.SignalSerializer; import io.opentelemetry.sdk.common.CompletableResultCode; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/StorageConfiguration.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/StorageConfiguration.java similarity index 98% rename from disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/StorageConfiguration.java rename to disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/StorageConfiguration.java index 1458f0548..d47797f9e 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/StorageConfiguration.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/StorageConfiguration.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.contrib.disk.buffering.internal; +package io.opentelemetry.contrib.disk.buffering; import com.google.auto.value.AutoValue; import io.opentelemetry.contrib.disk.buffering.internal.files.DefaultTemporaryFileProvider; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/FromDiskExporterBuilder.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/FromDiskExporterBuilder.java index 55dac5438..4008bd1f9 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/FromDiskExporterBuilder.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/FromDiskExporterBuilder.java @@ -8,7 +8,7 @@ import static java.util.Collections.emptyList; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.serialization.deserializers.SignalDeserializer; import io.opentelemetry.contrib.disk.buffering.internal.storage.Storage; import io.opentelemetry.contrib.disk.buffering.internal.storage.StorageBuilder; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilder.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilder.java index 630e2f7ce..158eae60b 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilder.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilder.java @@ -6,7 +6,7 @@ package io.opentelemetry.contrib.disk.buffering.internal.exporter; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers.SignalSerializer; import io.opentelemetry.contrib.disk.buffering.internal.storage.Storage; import io.opentelemetry.contrib.disk.buffering.internal.storage.StorageBuilder; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java index 45e66fdeb..23bf52b92 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java @@ -7,7 +7,7 @@ import static io.opentelemetry.contrib.disk.buffering.internal.storage.util.ClockBuddy.nowMillis; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.storage.files.ReadableFile; import io.opentelemetry.contrib.disk.buffering.internal.storage.files.WritableFile; import io.opentelemetry.sdk.common.Clock; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageBuilder.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageBuilder.java index ee5540ea9..dd86d67c2 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageBuilder.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/StorageBuilder.java @@ -6,7 +6,7 @@ package io.opentelemetry.contrib.disk.buffering.internal.storage; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.sdk.common.Clock; import java.io.File; import java.io.IOException; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFile.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFile.java index 049de1bd9..876f7377b 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFile.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFile.java @@ -7,7 +7,7 @@ import static io.opentelemetry.contrib.disk.buffering.internal.storage.util.ClockBuddy.nowMillis; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.storage.files.reader.DelimitedProtoStreamReader; import io.opentelemetry.contrib.disk.buffering.internal.storage.files.reader.ReadResult; import io.opentelemetry.contrib.disk.buffering.internal.storage.files.reader.StreamReader; diff --git a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFile.java b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFile.java index f72fd7d6c..ad63d1d71 100644 --- a/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFile.java +++ b/disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFile.java @@ -7,7 +7,7 @@ import static io.opentelemetry.contrib.disk.buffering.internal.storage.util.ClockBuddy.nowMillis; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.storage.responses.WritableResult; import io.opentelemetry.sdk.common.Clock; import java.io.File; diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java index 996fc9b83..24b5ed8cf 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/IntegrationTest.java @@ -16,7 +16,6 @@ import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.Tracer; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporterBuilder; import io.opentelemetry.contrib.disk.buffering.internal.exporter.FromDiskExporterImpl; import io.opentelemetry.contrib.disk.buffering.internal.exporter.ToDiskExporter; diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporterTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporterTest.java index 511894922..87e796896 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporterTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporterTest.java @@ -19,7 +19,6 @@ import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.files.DefaultTemporaryFileProvider; import io.opentelemetry.contrib.disk.buffering.internal.serialization.mapping.spans.models.SpanDataImpl; import io.opentelemetry.contrib.disk.buffering.internal.serialization.serializers.SignalSerializer; diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilderTest.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilderTest.java index 050fa65a3..8100b515d 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilderTest.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporterBuilderTest.java @@ -7,7 +7,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.sdk.trace.data.SpanData; import java.io.File; import org.junit.jupiter.api.Test; diff --git a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/TestData.java b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/TestData.java index 883c5dc18..06983a886 100644 --- a/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/TestData.java +++ b/disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/storage/TestData.java @@ -5,7 +5,7 @@ package io.opentelemetry.contrib.disk.buffering.internal.storage; -import io.opentelemetry.contrib.disk.buffering.internal.StorageConfiguration; +import io.opentelemetry.contrib.disk.buffering.StorageConfiguration; import io.opentelemetry.contrib.disk.buffering.internal.files.DefaultTemporaryFileProvider; import io.opentelemetry.contrib.disk.buffering.internal.files.TemporaryFileProvider; import java.io.File;