Add persistent storage to exporter - Public API (#1359)
* Storage Public API * PR feedback * Renamed from IOffline to IPersistent * Update copyright * PutBlob with IPersistentBlob * Reword GetBlobs * Change PutBlob signature * Update Lease summary * Update src/OpenTelemetry.Shared/IPersistentBlob.cs Co-authored-by: Reiley Yang <reyang@microsoft.com> * PR feedback Co-authored-by: Cijo Thomas <cithomas@microsoft.com> Co-authored-by: Reiley Yang <reyang@microsoft.com>
This commit is contained in:
parent
1170f3f20d
commit
de2f115094
|
|
@ -202,6 +202,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.InMe
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\logs\extending-the-sdk\extending-the-sdk.csproj", "{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Shared", "src\OpenTelemetry.Shared\OpenTelemetry.Shared.csproj", "{1E504265-1E32-4C61-8CC5-8FA373E16699}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -396,6 +398,10 @@ Global
|
|||
{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1E504265-1E32-4C61-8CC5-8FA373E16699}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1E504265-1E32-4C61-8CC5-8FA373E16699}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1E504265-1E32-4C61-8CC5-8FA373E16699}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1E504265-1E32-4C61-8CC5-8FA373E16699}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
// <copyright file="IPersistentBlob.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// API to Read, Write and Delete a blob.
|
||||
/// </summary>
|
||||
public interface IPersistentBlob
|
||||
{
|
||||
/// <summary>
|
||||
/// Read content of a blob from storage.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Blob content.
|
||||
/// </returns>
|
||||
public byte[] Read();
|
||||
|
||||
/// <summary>
|
||||
/// Write a blob content to storage.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// Buffer to write to storage.
|
||||
/// </param>
|
||||
/// <param name="leasePeriodMilliseconds">
|
||||
/// Lease period in milliseconds.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A blob if there is an available one, or null if there is no blob available.
|
||||
/// </returns>
|
||||
public IPersistentBlob Write(byte[] buffer, int leasePeriodMilliseconds = 0);
|
||||
|
||||
/// <summary>
|
||||
/// Create and manage a lease on the blob.
|
||||
/// </summary>
|
||||
/// <param name="leasePeriodMilliseconds">
|
||||
/// Lease period in milliseconds.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A blob if there is an available one, or null if there is no blob available.
|
||||
/// </returns>
|
||||
public IPersistentBlob Lease(int leasePeriodMilliseconds);
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to delete the blob.
|
||||
/// </summary>
|
||||
public void Delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
// <copyright file="IPersistentStorage.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenTelemetry.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Persistent storage API.
|
||||
/// </summary>
|
||||
public interface IPersistentStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Read a sequence of blobs from storage.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Sequence of blobs from storage.
|
||||
/// </returns>
|
||||
public IEnumerable<IPersistentBlob> GetBlobs();
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to get a blob from storage.
|
||||
/// This function never throws.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// A blob if there is an available one, or null if there is no blob available.
|
||||
/// </returns>
|
||||
IPersistentBlob GetBlob();
|
||||
|
||||
/// <summary>
|
||||
/// Create a new blob with the provided data.
|
||||
/// </summary>
|
||||
/// <param name="buffer">
|
||||
/// Blob content.
|
||||
/// </param>
|
||||
/// <param name="leasePeriodMilliseconds">
|
||||
/// Lease period in milliseconds.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A blob if there is an available one, or null if there is no blob available.
|
||||
/// </returns>
|
||||
public IPersistentBlob CreateBlob(byte[] buffer, int leasePeriodMilliseconds = 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net452;net46;net461;netstandard2.0</TargetFrameworks>
|
||||
<Description>Shared project for OpenTelemetry .NET</Description>
|
||||
<PackageTags>$(PackageTags);Shared</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>$(NoWarn),1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in New Issue