-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tamilanban/wcf-action-null-reference
- Loading branch information
Showing
27 changed files
with
1,465 additions
and
45 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
.github/workflows/package-Extensions.PersistentStorage.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Pack OpenTelemetry.Contrib.Extensions.PersistentStorage | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: 'Log level' | ||
required: true | ||
default: 'warning' | ||
push: | ||
tags: | ||
- 'Extensions.PersistentStorage-*' # trigger when we create a tag with prefix "Extensions.PersistentStorage-" | ||
|
||
jobs: | ||
build-test-pack: | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
PROJECT: OpenTelemetry.Contrib.Extensions.PersistentStorage | ||
|
||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # fetching all | ||
|
||
- name: Install dependencies | ||
run: dotnet restore | ||
|
||
- name: dotnet build ${{env.PROJECT}} | ||
run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true | ||
|
||
- name: dotnet test ${{env.PROJECT}} | ||
run: dotnet test test/${{env.PROJECT}}.Tests | ||
|
||
- name: dotnet pack ${{env.PROJECT}} | ||
run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build | ||
|
||
- name: Publish Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{env.PROJECT}}-packages | ||
path: '**/${{env.PROJECT}}/bin/**/*.*nupkg' | ||
|
||
- name: Publish Nuget | ||
run: | | ||
nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/OpenTelemetry.Contrib.Extensions.PersistentStorage/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// <copyright file="AssemblyInfo.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.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("OpenTelemetry.Contrib.Extensions.PersistentStorage.Tests" + AssemblyInfo.PublicKey)] | ||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)] | ||
|
||
#if SIGNED | ||
internal static class AssemblyInfo | ||
{ | ||
public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898"; | ||
public const string MoqPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7"; | ||
} | ||
#else | ||
internal static class AssemblyInfo | ||
{ | ||
public const string PublicKey = ""; | ||
public const string MoqPublicKey = ""; | ||
} | ||
#endif |
9 changes: 9 additions & 0 deletions
9
src/OpenTelemetry.Contrib.Extensions.PersistentStorage/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Changelog - OpenTelemetry.Contrib.Extensions.PersistentStorage | ||
|
||
## 1.0.0-alpha2 | ||
|
||
This is the first release for the `OpenTelemetry.Contrib.Extensions.PersistentStorage` | ||
project. | ||
|
||
For more details, please refer to the | ||
[README](README.md) |
120 changes: 120 additions & 0 deletions
120
src/OpenTelemetry.Contrib.Extensions.PersistentStorage/FileBlob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// <copyright file="FileBlob.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; | ||
using System.IO; | ||
|
||
namespace OpenTelemetry.Contrib.Extensions.PersistentStorage | ||
{ | ||
/// <summary> | ||
/// The <see cref="FileBlob"/> allows to save a blob | ||
/// in file storage. | ||
/// </summary> | ||
public class FileBlob : IPersistentBlob | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FileBlob"/> | ||
/// class. | ||
/// </summary> | ||
/// <param name="fullPath">Absolute file path of the blob.</param> | ||
public FileBlob(string fullPath) | ||
{ | ||
this.FullPath = fullPath; | ||
} | ||
|
||
public string FullPath { get; private set; } | ||
|
||
/// <inheritdoc/> | ||
public byte[] Read() | ||
{ | ||
try | ||
{ | ||
return File.ReadAllBytes(this.FullPath); | ||
} | ||
catch (Exception ex) | ||
{ | ||
PersistentStorageEventSource.Log.Warning($"Reading a blob from file {this.FullPath} has failed.", ex); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public IPersistentBlob Write(byte[] buffer, int leasePeriodMilliseconds = 0) | ||
{ | ||
string path = this.FullPath + ".tmp"; | ||
|
||
try | ||
{ | ||
PersistentStorageHelper.WriteAllBytes(path, buffer); | ||
|
||
if (leasePeriodMilliseconds > 0) | ||
{ | ||
var timestamp = DateTime.UtcNow + TimeSpan.FromMilliseconds(leasePeriodMilliseconds); | ||
this.FullPath += $"@{timestamp:yyyy-MM-ddTHHmmss.fffffffZ}.lock"; | ||
} | ||
|
||
File.Move(path, this.FullPath); | ||
} | ||
catch (Exception ex) | ||
{ | ||
PersistentStorageEventSource.Log.Warning($"Writing a blob to file {path} has failed.", ex); | ||
return null; | ||
} | ||
|
||
return this; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public IPersistentBlob Lease(int leasePeriodMilliseconds) | ||
{ | ||
var path = this.FullPath; | ||
var leaseTimestamp = DateTime.UtcNow + TimeSpan.FromMilliseconds(leasePeriodMilliseconds); | ||
if (path.EndsWith(".lock", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
path = path.Substring(0, path.LastIndexOf('@')); | ||
} | ||
|
||
path += $"@{leaseTimestamp:yyyy-MM-ddTHHmmss.fffffffZ}.lock"; | ||
|
||
try | ||
{ | ||
File.Move(this.FullPath, path); | ||
} | ||
catch (Exception ex) | ||
{ | ||
PersistentStorageEventSource.Log.Warning($"Acquiring a lease to file {this.FullPath} has failed.", ex); | ||
return null; | ||
} | ||
|
||
this.FullPath = path; | ||
return this; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Delete() | ||
{ | ||
try | ||
{ | ||
PersistentStorageHelper.RemoveFile(this.FullPath); | ||
} | ||
catch (Exception ex) | ||
{ | ||
PersistentStorageEventSource.Log.Warning($"Deletion of file blob {this.FullPath} has failed.", ex); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.