![]() |
VOOZH | about |
dotnet add package OpenTelemetry.PersistentStorage.FileSystem --version 1.1.0
NuGet\Install-Package OpenTelemetry.PersistentStorage.FileSystem -Version 1.1.0
<PackageReference Include="OpenTelemetry.PersistentStorage.FileSystem" Version="1.1.0" />
<PackageVersion Include="OpenTelemetry.PersistentStorage.FileSystem" Version="1.1.0" />Directory.Packages.props
<PackageReference Include="OpenTelemetry.PersistentStorage.FileSystem" />Project file
paket add OpenTelemetry.PersistentStorage.FileSystem --version 1.1.0
#r "nuget: OpenTelemetry.PersistentStorage.FileSystem, 1.1.0"
#:package OpenTelemetry.PersistentStorage.FileSystem@1.1.0
#addin nuget:?package=OpenTelemetry.PersistentStorage.FileSystem&version=1.1.0Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.PersistentStorage.FileSystem&version=1.1.0Install as a Cake Tool
| Status | |
|---|---|
| Stability | Stable |
| Code Owners | @rajkumar-rangaraj |
👁 NuGet version badge
👁 NuGet download count badge
👁 codecov.io
This package provides an implementation of persistent-storage-abstractions based on local file system. This component can be used by OpenTelemetry exporters to improve the reliability of data delivery.
dotnet add package OpenTelemetry.PersistentStorage.FileSystem
using var persistentBlobProvider = new FileBlobProvider(@"C:/temp");
Following is the complete list of parameters that FileBlobProvider constructor
accepts to control its configuration:
Sets directory location where blobs are stored. Required.
Maximum allowed folder size. Optional. Default if not specified: 52428800
bytes.
New blobs are dropped after the folder size reaches maximum limit. A log message is written if blobs cannot be written. See Troubleshooting for more information.
Maintenance event runs at specified interval. Optional. Default if not
specified: 120000ms.
During this event, the following tasks are performed:
*.blob files for which the retention period has expired.*.tmp files for which the write timeout period has expired.*.lock files to *.blob for which the lease period has expired.For more details on file extensions(.blob, .tmp, .lock) see File naming section below.
File retention period in milliseconds for the blob. Optional. Default if not
specified: 172800000ms.
Controls the timeout when writing a buffer to blob. Optional. Default if not
specified: 60000ms.
TryCreateBlob(byte[] buffer, out PersistentBlob blob) or TryCreateBlob(byte[] buffer, int leasePeriodMilliseconds = 0, out PersistentBlob blob) can be used
to create a blob (single file). The file stored will have .blob
extension. If acquiring lease, the file will have .lock extension.
// Try create blob without acquiring lease
persistentBlobProvider.TryCreateBlob(data, out var blob);
// Try create blob and acquire lease
persistentBlobProvider.TryCreateBlob(data, 1000, out var blob);
TryGetBlob can be used to read single blob or GetBlobs can be used to get list
of all blobs stored on disk. The result will only include files with .blob
extension.
// Get single blob from storage.
persistentBlobProvider.GetBlob(out var blob);
// List all blobs.
foreach (var blobItem in persistentBlobProvider.GetBlobs())
{
Console.WriteLine(((FileBlob)blobItem).FullPath);
}
When reading data back from disk, TryLease(int leasePeriodMilliseconds) method
should be used first to acquire lease on blob. This prevents it to be read
concurrently, until the lease period expires. Leasing a blob changes the file
extension to .lock.
blob.TryLease(1000);
Once the lease is acquired on the blob, the data can be read using
TryRead(out var data) method.
blob.TryRead(out var data);
TryDelete method can be used to delete the blob.
blob.TryDelete();
using var persistentBlobProvider = new FileBlobProvider(@"C:/temp");
var data = Encoding.UTF8.GetBytes("Hello, World!");
// Create blob.
persistentBlobProvider.TryCreateBlob(data, out var createdBlob);
// List all blobs.
foreach (var blobItem in persistentBlobProvider.GetBlobs())
{
Console.WriteLine(((FileBlob)blobItem).FullPath);
}
// Get single blob.
if (persistentBlobProvider.TryGetBlob(out var blob))
{
// Lease before reading
if (blob.TryLease(1000))
{
// Read
if (blob.TryRead(out var outputData))
{
Console.WriteLine(Encoding.UTF8.GetString(outputData));
}
// Delete
if (blob.TryDelete())
{
Console.WriteLine("Successfully deleted the blob");
}
}
}
Each call to CreateBlob methods create a single file(blob) at the
configured directory path. Each file that is created has unique name in
the format datetimestamp(ISO 8601)-GUID with current datetime. The file
extension depends on the operation. When creating a blob, the file is stored
with the .blob extension. If a lease is acquired on an existing file or on the
file being created, the file extension is changed to .lock, along with the
lease expiration time appended to its name in the format @datetimestamp(ISO 8601). The .tmp extension is used for files while data writing is in process.
Example file names:
2024-05-15T174825.3027972Z-40386ee02b8a47f1b04afc281f33d712.blob2024-05-15T174825.3027972Z-40386ee02b8a47f1b04afc281f33d712.blob@2024-05-15T203551.2932278Z.lock2024-05-15T175941.2228167Z-6649ff8ce55144b88a99c440a0b9feea.blob.tmpThe data contained within the file(blob) is unencrypted and stored in its original, unprocessed format provided in the byte array. If there is a privacy concern, application owners SHOULD review and restrict the collection of private data. If specific security requirements need to be met, application owners SHOULD configure the directory to restrict access (ensuring that the process running your application has write access to this directory), thus preventing unauthorized users from reading its contents.
A blob stored on disk persists until it is explicitly deleted using the TryDelete operation or is removed during the maintenance job upon the expiration of its retention period.
This component uses an EventSource with the name "OpenTelemetry-PersistentStorage-FileSystem" for its internal logging. Please follow the troubleshooting guide for OpenTelemetry .NET for instructions on how to capture the logs.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on OpenTelemetry.PersistentStorage.FileSystem:
| Package | Downloads |
|---|---|
|
Azure.Monitor.OpenTelemetry.Exporter
An OpenTelemetry .NET exporter that exports to Azure Monitor |
|
|
Zongsoft.Diagnostics
This is a class library for OpenTelemetry protocols. |
Showing the top 4 popular GitHub repositories that depend on OpenTelemetry.PersistentStorage.FileSystem:
| Repository | Stars |
|---|---|
|
Azure/azure-sdk-for-net
This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
|
|
|
doghappy/socket.io-client-csharp
socket.io-client implemention for .NET
|
|
|
Bassman2/MediaDevices
MTP Library
|
|
|
Dixin/Blog
Code examples for blog https://weblogs.asp.net/dixin.
|