11# Design Overview
22
3- There are three main disk-writing exporters provided by this module:
3+ The core of disk buffering
4+ is [ SignalStorage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/SignalStorage.java ) .
5+ SignalStorage is an abstraction that defines the bare minimum functionalities needed for
6+ implementations to allow writing and reading signals.
47
5- * [ LogRecordToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordToDiskExporter.java )
6- * [ MetricToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/MetricToDiskExporter.java )
7- * [ SpanToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/SpanToDiskExporter.java ) )
8+ There is a default implementation per signal that writes serialized signal items to protobuf
9+ delimited messages into files, where each file's name represents a timestamp of when it was created,
10+ which will help later to know when it's ready to read, as well as when it's expired. These
11+ implementations are the following:
812
9- Each is responsible for writing a specific type of telemetry to disk storage for later
10- harvest/ingest.
13+ * [ FileSpanStorage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/impl/FileSpanStorage.java )
14+ * [ FileLogRecordStorage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/impl/FileLogRecordStorage.java )
15+ * [ FileMetricStorage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/impl/FileMetricStorage.java )
1116
12- For later reading, there are:
17+ Each one has a ` create() ` method that takes a destination directory (to store data into) and an
18+ optional [ FileStorageConfiguration] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/impl/FileStorageConfiguration.java )
19+ to have a finer control of the storing behavior.
1320
14- * [ LogRecordFromToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/LogRecordFromDiskExporter.java )
15- * [ MetricFromDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/MetricFromDiskExporter.java )
16- * [ SpanFromDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/SpanFromDiskExporter.java ) )
21+ Even
22+ though [ SignalStorage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/SignalStorage.java )
23+ can receive signal items directly to be stored in disk, there are convenience exporter
24+ implementations for each signal that handle the storing process on your behalf. Those are the
25+ following:
1726
18- Each one of those has a ` create() ` method that takes a delegate exporter (to send data
19- to ingest) and the ` StorageConfiguration ` that tells them where to find buffered data.
27+ * [ SpanToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/exporters/SpanToDiskExporter.java )
28+ * [ LogRecordToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/exporters/LogRecordToDiskExporter.java )
29+ * [ MetricToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/exporters/MetricToDiskExporter.java )
2030
21- As explained in the [ README] ( README.md ) , this has to be triggered manually by the consumer of
22- this library and does not happen automatically.
31+ Each receive their
32+ respective [ SignalStorage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/storage/SignalStorage.java )
33+ object to delegate signals to as well as an optional callback object to notify its operations.
2334
2435## Writing overview
2536
2637![ Writing flow] ( assets/writing-flow.png )
2738
28- * The writing process happens automatically within its ` export(Collection<SignalData> signals) `
29- method, which is called by the configured signal processor.
30- * When a set of signals is received, these are delegated over to
31- a type-specific wrapper of [ ToDiskExporter] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/exporter/ToDiskExporter.java )
32- class which then serializes them using an implementation
33- of [ SignalSerializer] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/serializers/SignalSerializer.java )
34- and then the serialized data is appended into a File using an instance of
35- the [ Storage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/Storage.java )
36- class.
39+ * Via the convenience toDisk exporters, the writing process happens automatically within their
40+ ` export(Collection<SignalData> signals) ` method, which is called by the configured signal
41+ processor.
42+ * When a set of signals is received, these are delegated over to a type-specific serializer
43+ and then the serialized data is appended into a file.
3744* The data is written into a file directly, without the use of a buffer, to make sure no data gets
3845 lost in case the application ends unexpectedly.
39- * Each disk exporter stores its signals in its own folder, which is expected to contain files
46+ * Each signal storage stores its signals in its own folder, which is expected to contain files
4047 that belong to that type of signal only.
4148* Each file may contain more than a batch of signals if the configuration parameters allow enough
4249 limit size for it.
4350* If the configured folder size for the signals has been reached and a new file is needed to be
4451 created to keep storing new data, the oldest available file will be removed to make space for the
4552 new one.
46- * The [ Storage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/Storage.java ) ,
47- [ FolderManager] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java )
48- and [ WritableFile] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/WritableFile.java )
49- files contain more information on the details of the writing process into a file.
5053
5154## Reading overview
5255
5356![ Reading flow] ( assets/reading-flow.png )
5457
55- * The reading process has to be triggered manually by the library consumer as explained in
56- the [ README ] ( README.md ) .
58+ * The reading process has to be triggered manually by the library consumer via the signal storage
59+ iterator .
5760* A single file is read at a time and updated to remove the data gathered from it after it is
5861 successfully exported, until it's emptied. Each file previously created during the
5962 writing process has a timestamp in milliseconds, which is used to determine what file to start
@@ -62,9 +65,3 @@ this library and does not happen automatically.
6265 the time of creating the disk exporter, then it will be ignored, and the next oldest (and
6366 unexpired) one will be used instead.
6467* All the stale and empty files will be removed as a new file is created.
65- * The [ Storage] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/Storage.java ) ,
66- [ FolderManager] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/FolderManager.java )
67- and [ ReadableFile] ( src/main/java/io/opentelemetry/contrib/disk/buffering/internal/storage/files/ReadableFile.java )
68- files contain more information on the details of the file reading process.
69- * Note that the reader delegates the data to the exporter exactly in the way it has received the
70- data - it does not try to batch data (but this could be an optimization in the future).
0 commit comments