Skip to content

Commit

Permalink
Merge branch 'main' into tamilanban/wcf-action-null-reference
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch authored Feb 5, 2022
2 parents cb84aa7 + fa906bd commit d7fff85
Show file tree
Hide file tree
Showing 27 changed files with 1,465 additions and 45 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/package-Extensions.PersistentStorage.yml
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 }}
2 changes: 1 addition & 1 deletion .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
os: [windows-latest,ubuntu-latest]
version: [net461,netcoreapp2.1,netcoreapp3.1,net5.0]
version: [net461,netcoreapp3.1,net5.0]
exclude:
- os: ubuntu-latest
version: net461
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ src/OpenTelemetry.Contrib.Instrumentation.MassTransit/ @ope
src/OpenTelemetry.Contrib.Instrumentation.Owin/ @open-telemetry/dotnet-contrib-approvers @codeblanch
src/OpenTelemetry.Contrib.Instrumentation.Wcf/ @open-telemetry/dotnet-contrib-approvers @codeblanch
src/OpenTelemetry.Contrib.Instrumentation.MySqlData/ @open-telemetry/dotnet-contrib-approvers @moonheart
src/OpenTelemetry.Contrib.Extensions.PersistentStorage/ @open-telemetry/dotnet-contrib-approvers @vishweshbankwar
src/OpenTelemetry.Contrib.Preview/ @open-telemetry/dotnet-contrib-approvers @codeblanch

test/OpenTelemetry.Contrib.Exporter.Stackdriver.Tests/ @open-telemetry/dotnet-contrib-approvers @SergeyKanzhelev
Expand All @@ -24,4 +25,5 @@ test/OpenTelemetry.Contrib.Instrumentation.MassTransit.Tests/ @ope
test/OpenTelemetry.Contrib.Instrumentation.Owin.Tests/ @open-telemetry/dotnet-contrib-approvers @codeblanch
test/OpenTelemetry.Contrib.Instrumentation.Wcf.Tests/ @open-telemetry/dotnet-contrib-approvers @codeblanch
test/OpenTelemetry.Contrib.Instrumentation.MySqlData.Tests/ @open-telemetry/dotnet-contrib-approvers @moonheart
test/OpenTelemetry.Contrib.Extensions.PersistentStorage.Tests/ @open-telemetry/dotnet-contrib-approvers @vishweshbankwar
test/OpenTelemetry.Contrib.Preview.Tests/ @open-telemetry/dotnet-contrib-approvers @codeblanch
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ Any Maintainer can merge the PR once it is **ready to merge**. Note, that some
PR may not be merged immediately if repo is being in process of a major release
and the new feature doesn't fit it.

### How to request for release of package

Submit a PR with `CHANGELOG.md` file reflecting the version to be released. Also,
tag the maintainers of this repository who can release the package.

## Style Guide

This project includes a
Expand Down Expand Up @@ -193,3 +198,6 @@ to be placed in the `.github/workflows/` folder.
value to "Foo.Bar-*" and
[`PROJECT`](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/main/.github/workflows/package-Extensions.AWSXRay.yml#L18)
value to "OpenTelemetry.Contrib.Foo.Bar".

* When contributing a new project you are expected to assign yourself to your
project in the [CODEOWNERS](./CODEOWNERS) file
41 changes: 6 additions & 35 deletions build/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,10 @@ update the Changelog.

This will trigger the building and packaging workflow for the project.

2. Navigate to the [**Actions**](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/actions)
tab on the repo and monitor the "Pack YOUR_PROJECT_NAME" workflow. The last
step in the workflow is to publish to MyGet.
2. Navigate to the
[**Actions**](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/actions)
tab on the repo and monitor the "Pack YOUR_PROJECT_NAME" workflow. The last step
in the workflow is to publish to Nuget.org.

3. Validate that the project has been published to MyGet with the latest
version that you had specified in step 1.

4. Get the build artifact .zip from the workflow execution in step 2.
Extract the artifact to a local folder. This should contain the nuget
files and symbols.

5. Download the latest [nuget.exe](https://www.nuget.org/downloads) into
the same folder as step 4.

6. Publish the project to nuget.org

```powershell
.\nuget.exe setApiKey <NUGET TOKEN>
```
```powershell
get-childitem -Recurse | where {$_.extension -eq ".nupkg"} | foreach
($_) {.\nuget.exe push $_.fullname
-Source https://api.nuget.org/v3/index.json}
```
It usually takes a while for the new version of the project to show up in nuget.org
7. Validate that the new version of the project is successfully published to
nuget.org under OpenTelemetry owner.
8. Delete the NUGET TOKEN set in step 6.
9. Go to the [**Releases**](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/releases)
page on the repo. Create a new release with the tag from step 1. Include the
Changelog from your project to the release notes.
3. Validate that the new version (as specified in step1) of the project is
successfully published to nuget.org under OpenTelemetry owner.
14 changes: 14 additions & 0 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Owin", "examples\o
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Contrib.Instrumentation.Owin.Tests", "test\OpenTelemetry.Contrib.Instrumentation.Owin.Tests\OpenTelemetry.Contrib.Instrumentation.Owin.Tests.csproj", "{D52558C8-B7BF-4F59-A0FA-9AA629E68012}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Contrib.Extensions.PersistentStorage", "src\OpenTelemetry.Contrib.Extensions.PersistentStorage\OpenTelemetry.Contrib.Extensions.PersistentStorage.csproj", "{433C59A3-D535-421E-BA7F-9BCE0D4A3D25}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Contrib.Extensions.PersistentStorage.Tests", "test\OpenTelemetry.Contrib.Extensions.PersistentStorage.Tests\OpenTelemetry.Contrib.Extensions.PersistentStorage.Tests.csproj", "{72EBA81D-2933-417C-8F21-D4CFFD72F530}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -294,6 +298,14 @@ Global
{D52558C8-B7BF-4F59-A0FA-9AA629E68012}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D52558C8-B7BF-4F59-A0FA-9AA629E68012}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D52558C8-B7BF-4F59-A0FA-9AA629E68012}.Release|Any CPU.Build.0 = Release|Any CPU
{433C59A3-D535-421E-BA7F-9BCE0D4A3D25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{433C59A3-D535-421E-BA7F-9BCE0D4A3D25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{433C59A3-D535-421E-BA7F-9BCE0D4A3D25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{433C59A3-D535-421E-BA7F-9BCE0D4A3D25}.Release|Any CPU.Build.0 = Release|Any CPU
{72EBA81D-2933-417C-8F21-D4CFFD72F530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72EBA81D-2933-417C-8F21-D4CFFD72F530}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72EBA81D-2933-417C-8F21-D4CFFD72F530}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72EBA81D-2933-417C-8F21-D4CFFD72F530}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -339,6 +351,8 @@ Global
{8D11A34C-D0EF-4DE1-8230-32168E67044D} = {B75EE478-97F7-4E9F-9A5A-DB3D0988EDEA}
{6B3AA3F2-89A7-433F-918A-1E5E6AAF8423} = {8D11A34C-D0EF-4DE1-8230-32168E67044D}
{D52558C8-B7BF-4F59-A0FA-9AA629E68012} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
{433C59A3-D535-421E-BA7F-9BCE0D4A3D25} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{72EBA81D-2933-417C-8F21-D4CFFD72F530} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased
## 1.0.0-beta1

* Update OTel SDK package version to 1.1.0
* Log exceptions when failing to export data to stackdriver
Expand Down
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
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 src/OpenTelemetry.Contrib.Extensions.PersistentStorage/FileBlob.cs
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);
}
}
}
}
Loading

0 comments on commit d7fff85

Please sign in to comment.