diff --git a/.github/.github.csproj b/.github/.github.csproj new file mode 100644 index 0000000..568bf7d --- /dev/null +++ b/.github/.github.csproj @@ -0,0 +1,7 @@ + + + net8.0 + False + + + diff --git a/.github/add-license-headers.sh b/.github/add-license-headers.sh new file mode 100755 index 0000000..9831281 --- /dev/null +++ b/.github/add-license-headers.sh @@ -0,0 +1,14 @@ +#!/bin/bash +script_path=$(dirname $(realpath $0))/../ + +function add_license () { + (find "$script_path" -name $1 | grep -v "/bin/" | grep -v "/obj/" )|while read fname; do + line=$(sed -n '2p;3q' "$fname") + if ! [[ "$line" == " * Licensed to Elasticsearch B.V. under one or more contributor" ]] ; then + cat "${script_path}.github/license-header.txt" "$fname" > "${fname}.new" + mv "${fname}.new" "$fname" + fi + done +} + +add_license "*.cs" diff --git a/.github/check-license-headers.sh b/.github/check-license-headers.sh new file mode 100755 index 0000000..d80c95a --- /dev/null +++ b/.github/check-license-headers.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Check that source code files in this repo have the appropriate license +# header. + +if [ "$TRACE" != "" ]; then + export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + set -o xtrace +fi +set -o errexit +set -o pipefail + +TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd) +NLINES=$(wc -l .github/license-header.txt | awk '{print $1}') + +function check_license_header { + local f + f=$1 + if ! diff .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then + echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES $f)'" + return 1 + else + return 0 + fi +} + +cd "$TOP" +nErrors=0 +for f in $(git ls-files | grep '\.cs$'); do + if ! check_license_header $f; then + nErrors=$((nErrors+1)) + fi +done + +for f in $(git ls-files | grep '\.fs$'); do + if ! check_license_header $f; then + nErrors=$((nErrors+1)) + fi +done + +if [[ $nErrors -eq 0 ]]; then + exit 0 +else + exit 1 +fi \ No newline at end of file diff --git a/.github/license-header.txt b/.github/license-header.txt new file mode 100644 index 0000000..52c5ed5 --- /dev/null +++ b/.github/license-header.txt @@ -0,0 +1,3 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..633b490 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: Always be deploying + +on: + pull_request: + paths-ignore: + - 'README.md' + - '.editorconfig' + push: + paths-ignore: + - 'README.md' + - '.editorconfig' + branches: + - main + tags: + - "*.*.*" + +jobs: + test-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - run: | + git fetch --prune --unshallow --tags + echo exit code $? + git tag --list + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 8.0.x + 6.0.x + source-url: https://nuget.pkg.github.com/elastic/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - run: build.bat test + shell: cmd + name: Test + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - run: | + git fetch --prune --unshallow --tags + echo exit code $? + git tag --list + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 6.0.x + 8.0.x + source-url: https://nuget.pkg.github.com/elastic/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - run: ./build.sh release + name: Release + + - name: publish canary packages github package repository + if: github.event_name == 'push' && startswith(github.ref, 'refs/heads') + shell: bash + run: | + until dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate --no-symbols; do echo "Retrying"; sleep 1; done; + + # Github packages requires authentication, this is likely going away in the future so for now we publish to feedz.io + - run: dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.FEEDZ_IO_API_KEY}} -s https://f.feedz.io/elastic/all/nuget/index.json --skip-duplicate --no-symbols + name: publish canary packages to feedz.io + if: false && github.event_name == 'push' && startswith(github.ref, 'refs/heads') + + - run: dotnet nuget push 'build/output/*.nupkg' -k ${{secrets.NUGET_ORG_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols + name: release to nuget.org + if: false && github.event_name == 'push' && startswith(github.ref, 'refs/tags') diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml new file mode 100644 index 0000000..c42f591 --- /dev/null +++ b/.github/workflows/license.yml @@ -0,0 +1,15 @@ +name: License headers + +on: [pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Check license headers + run: | + ./.github/check-license-headers.sh \ No newline at end of file diff --git a/Elastic.OpenTelemetry.sln b/Elastic.OpenTelemetry.sln index e93ec81..6fb11d8 100644 --- a/Elastic.OpenTelemetry.sln +++ b/Elastic.OpenTelemetry.sln @@ -26,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AAD39891 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.OpenTelemetry.Tests", "tests\Elastic.OpenTelemetry.Tests\Elastic.OpenTelemetry.Tests.csproj", "{22BF9223-3A6D-4197-8527-3E4E43A98A81}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ".github", ".github\.github.csproj", "{B701E33D-D777-4BD4-A4EC-1F63FE69AF7A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -52,6 +54,10 @@ Global {22BF9223-3A6D-4197-8527-3E4E43A98A81}.Debug|Any CPU.Build.0 = Debug|Any CPU {22BF9223-3A6D-4197-8527-3E4E43A98A81}.Release|Any CPU.ActiveCfg = Release|Any CPU {22BF9223-3A6D-4197-8527-3E4E43A98A81}.Release|Any CPU.Build.0 = Release|Any CPU + {B701E33D-D777-4BD4-A4EC-1F63FE69AF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B701E33D-D777-4BD4-A4EC-1F63FE69AF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B701E33D-D777-4BD4-A4EC-1F63FE69AF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B701E33D-D777-4BD4-A4EC-1F63FE69AF7A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build.bat b/build.bat index 64d090f..6a58898 100644 --- a/build.bat +++ b/build.bat @@ -1,3 +1,3 @@ -@echo off -dotnet run --project build/scripts -- %* +@echo off +dotnet run --project build -c debug -- %* diff --git a/build.sh b/build.sh index b8feb2c..db63774 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash set -euo pipefail -dotnet run --project build -- "$@" +dotnet run --project build -c release -- "$@" diff --git a/build/build.fsproj b/build/build.fsproj index c047be2..6a4e88d 100644 --- a/build/build.fsproj +++ b/build/build.fsproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 Exe $(NoWarn);NU1701 false diff --git a/build/scripts/Targets.fs b/build/scripts/Targets.fs index 3bc30f7..da74952 100644 --- a/build/scripts/Targets.fs +++ b/build/scripts/Targets.fs @@ -14,10 +14,13 @@ open Proc.Fs open BuildInformation let private clean _ = - exec { run "dotnet" "clean" } - Shell.cleanDir Paths.ArtifactFolder.FullName + exec { run "dotnet" "clean" "-c" "release" } + let removeArtifacts folder = Shell.cleanDir (Paths.ArtifactPath folder).FullName + removeArtifacts "package" + removeArtifacts "release-notes" + removeArtifacts "tests" -let private build _ = exec { run "dotnet" "build" "-c" "Release" } +let private build _ = exec { run "dotnet" "build" "-c" "release" } let private release _ = printfn "release" @@ -42,9 +45,14 @@ let private test _ = let junitOutput = Path.Combine(testOutputPath.FullName, "junit-{assembly}-{framework}-test-results.xml") let loggerPathArgs = $"LogFilePath=%s{junitOutput}" let loggerArg = $"--logger:\"junit;%s{loggerPathArgs}\"" + let githubActionsLogger = $"--logger:\"GitHubActions;summary.includePassedTests=true\"" let tfmArgs = if OS.Current = OS.Windows then [] else ["-f"; "net8.0"] exec { - run "dotnet" (["test"; "-c"; "Release"; loggerArg] @ tfmArgs) + run "dotnet" ( + ["test"; "-c"; "release"; loggerArg; githubActionsLogger] + @ tfmArgs + @ ["--"; "RunConfiguration.CollectSourceInformation=true"] + ) } let private validatePackages _ = diff --git a/docs/docs.csproj b/docs/docs.csproj index e0a99f7..568bf7d 100644 --- a/docs/docs.csproj +++ b/docs/docs.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 False diff --git a/examples/Example.Elastic.OpenTelemetry/Program.cs b/examples/Example.Elastic.OpenTelemetry/Program.cs index d6c4b9c..4544a3a 100644 --- a/examples/Example.Elastic.OpenTelemetry/Program.cs +++ b/examples/Example.Elastic.OpenTelemetry/Program.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using Example.Elastic.OpenTelemetry; Console.WriteLine("Starting sample application."); diff --git a/examples/Example.Elastic.OpenTelemetry/Usage.cs b/examples/Example.Elastic.OpenTelemetry/Usage.cs index 61ac7b0..624fffd 100644 --- a/examples/Example.Elastic.OpenTelemetry/Usage.cs +++ b/examples/Example.Elastic.OpenTelemetry/Usage.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using System.Diagnostics; using Elastic.OpenTelemetry; using Elastic.OpenTelemetry.Extensions; diff --git a/src/Elastic.OpenTelemetry/Agent.cs b/src/Elastic.OpenTelemetry/Agent.cs index 4e5d339..2c73a33 100644 --- a/src/Elastic.OpenTelemetry/Agent.cs +++ b/src/Elastic.OpenTelemetry/Agent.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using OpenTelemetry; using System.Reflection; diff --git a/src/Elastic.OpenTelemetry/AgentBuilder.cs b/src/Elastic.OpenTelemetry/AgentBuilder.cs index 6872bc1..2315002 100644 --- a/src/Elastic.OpenTelemetry/AgentBuilder.cs +++ b/src/Elastic.OpenTelemetry/AgentBuilder.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using Elastic.OpenTelemetry.Extensions; using Elastic.OpenTelemetry.Resources; using OpenTelemetry; diff --git a/src/Elastic.OpenTelemetry/Exporters/BatchExporter.cs b/src/Elastic.OpenTelemetry/Exporters/BatchExporter.cs index c4e9406..d49d188 100644 --- a/src/Elastic.OpenTelemetry/Exporters/BatchExporter.cs +++ b/src/Elastic.OpenTelemetry/Exporters/BatchExporter.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using OpenTelemetry; using System.Diagnostics; diff --git a/src/Elastic.OpenTelemetry/Extensions/ActivityExtensions.cs b/src/Elastic.OpenTelemetry/Extensions/ActivityExtensions.cs index 4f9893d..27b5533 100644 --- a/src/Elastic.OpenTelemetry/Extensions/ActivityExtensions.cs +++ b/src/Elastic.OpenTelemetry/Extensions/ActivityExtensions.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using System.Diagnostics; using Elastic.OpenTelemetry.Processors; diff --git a/src/Elastic.OpenTelemetry/Extensions/MeterBuilderProviderExtensions.cs b/src/Elastic.OpenTelemetry/Extensions/MeterBuilderProviderExtensions.cs index 93544a4..0932b7c 100644 --- a/src/Elastic.OpenTelemetry/Extensions/MeterBuilderProviderExtensions.cs +++ b/src/Elastic.OpenTelemetry/Extensions/MeterBuilderProviderExtensions.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using OpenTelemetry.Metrics; namespace Elastic.OpenTelemetry.Extensions; diff --git a/src/Elastic.OpenTelemetry/Extensions/ResourceBuilderExtensions.cs b/src/Elastic.OpenTelemetry/Extensions/ResourceBuilderExtensions.cs index 49dbf1f..3ba830d 100644 --- a/src/Elastic.OpenTelemetry/Extensions/ResourceBuilderExtensions.cs +++ b/src/Elastic.OpenTelemetry/Extensions/ResourceBuilderExtensions.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using Elastic.OpenTelemetry.SemanticConventions; using OpenTelemetry.Resources; diff --git a/src/Elastic.OpenTelemetry/Extensions/TraceBuilderProviderExtensions.cs b/src/Elastic.OpenTelemetry/Extensions/TraceBuilderProviderExtensions.cs index aec2eca..4ae7bfc 100644 --- a/src/Elastic.OpenTelemetry/Extensions/TraceBuilderProviderExtensions.cs +++ b/src/Elastic.OpenTelemetry/Extensions/TraceBuilderProviderExtensions.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using Elastic.OpenTelemetry.Processors; using OpenTelemetry.Exporter; using OpenTelemetry.Trace; diff --git a/src/Elastic.OpenTelemetry/IAgent.cs b/src/Elastic.OpenTelemetry/IAgent.cs index 1a5a467..65d6668 100644 --- a/src/Elastic.OpenTelemetry/IAgent.cs +++ b/src/Elastic.OpenTelemetry/IAgent.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information namespace Elastic.OpenTelemetry; /// diff --git a/src/Elastic.OpenTelemetry/Processors/Composite.cs b/src/Elastic.OpenTelemetry/Processors/Composite.cs index d2dc71b..a388e02 100644 --- a/src/Elastic.OpenTelemetry/Processors/Composite.cs +++ b/src/Elastic.OpenTelemetry/Processors/Composite.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information namespace Elastic.OpenTelemetry.Processors; // TODO - Consider a struct, but consider if this would get copied too much diff --git a/src/Elastic.OpenTelemetry/Processors/SpanCompressionProcessor.cs b/src/Elastic.OpenTelemetry/Processors/SpanCompressionProcessor.cs index 19e48a4..3be03e0 100644 --- a/src/Elastic.OpenTelemetry/Processors/SpanCompressionProcessor.cs +++ b/src/Elastic.OpenTelemetry/Processors/SpanCompressionProcessor.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using Elastic.OpenTelemetry.Extensions; using OpenTelemetry; diff --git a/src/Elastic.OpenTelemetry/Processors/SpanCounterProcessor.cs b/src/Elastic.OpenTelemetry/Processors/SpanCounterProcessor.cs index 46f0cf4..0b602d3 100644 --- a/src/Elastic.OpenTelemetry/Processors/SpanCounterProcessor.cs +++ b/src/Elastic.OpenTelemetry/Processors/SpanCounterProcessor.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using OpenTelemetry; using System.Diagnostics; diff --git a/src/Elastic.OpenTelemetry/Processors/StackTraceProcessor.cs b/src/Elastic.OpenTelemetry/Processors/StackTraceProcessor.cs index 6d3e194..f14fd17 100644 --- a/src/Elastic.OpenTelemetry/Processors/StackTraceProcessor.cs +++ b/src/Elastic.OpenTelemetry/Processors/StackTraceProcessor.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using OpenTelemetry; using System.Diagnostics; diff --git a/src/Elastic.OpenTelemetry/Processors/TransactionIdProcessor.cs b/src/Elastic.OpenTelemetry/Processors/TransactionIdProcessor.cs index 2705a6b..5735069 100644 --- a/src/Elastic.OpenTelemetry/Processors/TransactionIdProcessor.cs +++ b/src/Elastic.OpenTelemetry/Processors/TransactionIdProcessor.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using OpenTelemetry; using System.Diagnostics; diff --git a/src/Elastic.OpenTelemetry/Resources/DefaultServiceDetector.cs b/src/Elastic.OpenTelemetry/Resources/DefaultServiceDetector.cs index a452d2a..971f1f2 100644 --- a/src/Elastic.OpenTelemetry/Resources/DefaultServiceDetector.cs +++ b/src/Elastic.OpenTelemetry/Resources/DefaultServiceDetector.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using System.Diagnostics; using Elastic.OpenTelemetry.SemanticConventions; using OpenTelemetry.Resources; diff --git a/src/Elastic.OpenTelemetry/Resources/ElasticEnvironmentVariableDetector.cs b/src/Elastic.OpenTelemetry/Resources/ElasticEnvironmentVariableDetector.cs index 427e460..64dcd73 100644 --- a/src/Elastic.OpenTelemetry/Resources/ElasticEnvironmentVariableDetector.cs +++ b/src/Elastic.OpenTelemetry/Resources/ElasticEnvironmentVariableDetector.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information using Elastic.OpenTelemetry.SemanticConventions; using OpenTelemetry.Resources; namespace Elastic.OpenTelemetry.Resources; diff --git a/src/Elastic.OpenTelemetry/SemanticConventions/ResourceSemanticConventions.cs b/src/Elastic.OpenTelemetry/SemanticConventions/ResourceSemanticConventions.cs index 26feee5..436aae4 100644 --- a/src/Elastic.OpenTelemetry/SemanticConventions/ResourceSemanticConventions.cs +++ b/src/Elastic.OpenTelemetry/SemanticConventions/ResourceSemanticConventions.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information namespace Elastic.OpenTelemetry.SemanticConventions; internal static class ResourceSemanticConventions diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 2d3ebd8..9bf0584 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -21,6 +21,7 @@ + diff --git a/tests/Elastic.OpenTelemetry.Tests/BasicAgentTest.cs b/tests/Elastic.OpenTelemetry.Tests/BasicAgentTest.cs index 5c3c237..b96b96c 100644 --- a/tests/Elastic.OpenTelemetry.Tests/BasicAgentTest.cs +++ b/tests/Elastic.OpenTelemetry.Tests/BasicAgentTest.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information namespace Elastic.OpenTelemetry.Tests; public class TransactionIdProcessorTests diff --git a/tests/Elastic.OpenTelemetry.Tests/GlobalUsings.cs b/tests/Elastic.OpenTelemetry.Tests/GlobalUsings.cs index 8fb8c95..febe4db 100644 --- a/tests/Elastic.OpenTelemetry.Tests/GlobalUsings.cs +++ b/tests/Elastic.OpenTelemetry.Tests/GlobalUsings.cs @@ -1,3 +1,6 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information global using Xunit; global using System.Diagnostics; global using Elastic.OpenTelemetry.Processors;