diff --git a/.github/codecov.yml b/.github/codecov.yml index ca71c9e68f..a6e4f68057 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -47,6 +47,12 @@ flags: paths: - src/OpenTelemetry.Exporter.OneCollector + unittests-Instrumentation.AspNet: + carryforward: true + paths: + - src/OpenTelemetry.Instrumentation.AspNet + - src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule + unittests-Instrumentation.Owin: carryforward: true paths: diff --git a/.github/workflows/Component.Package.yml b/.github/workflows/Component.Package.yml index 86fbccca33..65dd5afa5f 100644 --- a/.github/workflows/Component.Package.yml +++ b/.github/workflows/Component.Package.yml @@ -6,17 +6,18 @@ on: project-name: required: true type: string + release-name: + required: false + type: string + default: '' jobs: build-test-pack: permissions: contents: write - strategy: - matrix: - os: [windows-latest] + runs-on: windows-latest - runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: @@ -40,21 +41,58 @@ jobs: - name: Publish Artifacts uses: actions/upload-artifact@v3 with: - name: ${{ inputs.project-name }}-packages - path: '**/${{ inputs.project-name }}/bin/**/*.*nupkg' + name: ${{ inputs.project-name }}.proj-packages + path: 'src/*/bin/Release/*.*nupkg' - - name: Publish Nuget + - name: Publish NuGets run: | - nuget push **/${{ inputs.project-name }}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{ inputs.project-name }}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + nuget push src/*/bin/Release/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }} - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{ inputs.project-name }}/CHANGELOG.md) for details." --latest + shell: pwsh + run: | + $packages = (Get-ChildItem -Path src/*/bin/Release/*.nupkg).Name + + $notes = '' + $firstPackageVersion = '' + + foreach ($package in $packages) + { + $match = [regex]::Match($package, '(.*)\.(\d+\.\d+\.\d+.*?)\.nupkg') + $packageName = $match.Groups[1].Value + $packageVersion = $match.Groups[2].Value + + if ($firstPackageVersion -eq '') + { + $firstPackageVersion = $packageVersion + } + + $notes += + @" + * NuGet: [$packageName v$packageVersion](https://www.nuget.org/packages/$packageName/$packageVersion) + + See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/src/$packageName/CHANGELOG.md) for details. + + "@ + } + + $releaseName = '${{ inputs.release-name || inputs.project-name }}' + + if ($firstPackageVersion -contains '-alpha' -or $firstPackageVersion -contains '-beta' -or $firstPackageVersion -contains '-rc') + { + gh release create ${{ github.ref_name }} ` + --title "$releaseName v$firstPackageVersion" ` + --verify-tag ` + --notes "$notes" ` + --prerelease + } + else + { + gh release create ${{ github.ref_name }} ` + --title "$releaseName v$firstPackageVersion" ` + --verify-tag ` + --notes "$notes" ` + --latest + } env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f26727a29d..8b1572e8db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: build: ['build/**', '.github/**/*.yml', '!.github/workflows/package-*'] shared: ['src/Shared/**'] code: ['**.cs', '.editorconfig'] + aspnet: ['*/OpenTelemetry.Instrumentation.AspNet*/**', 'examples/AspNet/**', '!**/*.md'] geneva: ['*/OpenTelemetry.Exporter.Geneva*/**', '!**/*.md'] onecollector: ['*/OpenTelemetry.Instrumentation.OneCollector*/**', '!**/*.md'] owin: ['*/OpenTelemetry.Instrumentation.Owin*/**', 'examples/owin/**', '!**/*.md'] @@ -54,6 +55,19 @@ jobs: if: contains(needs.detect-changes.outputs.changes, 'code') uses: ./.github/workflows/dotnet-format.yml + build-test-aspnet: + needs: detect-changes + if: | + contains(needs.detect-changes.outputs.changes, 'aspnet') + || contains(needs.detect-changes.outputs.changes, 'build') + || contains(needs.detect-changes.outputs.changes, 'shared') + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.Instrumentation.AspNet + code-cov-name: Instrumentation.AspNet + os-list: '[ "windows-latest" ]' + tfm-list: '[ "net462" ]' + build-test-geneva: needs: detect-changes if: | @@ -167,6 +181,8 @@ jobs: -Exclude ` OpenTelemetry.Exporter.Geneva.Tests.csproj, OpenTelemetry.Exporter.OneCollector.Tests.csproj, + OpenTelemetry.Instrumentation.AspNet.Tests.csproj, + OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj, OpenTelemetry.Instrumentation.Owin.Tests.csproj, OpenTelemetry.Instrumentation.Process.Tests.csproj, OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj, @@ -200,6 +216,7 @@ jobs: detect-changes, lint-md, lint-dotnet-format, + build-test-aspnet, build-test-geneva, build-test-onecollector, build-test-owin, diff --git a/.github/workflows/package-Instrumentation.AspNet.TelemetryHttpModule.yml b/.github/workflows/package-Instrumentation.AspNet.TelemetryHttpModule.yml deleted file mode 100644 index 6cdd46856c..0000000000 --- a/.github/workflows/package-Instrumentation.AspNet.TelemetryHttpModule.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Pack OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule - -on: - workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - required: true - default: 'warning' - push: - tags: - - 'Instrumentation.AspNet.TelemetryHttpModule-*' - -jobs: - build-test-pack: - runs-on: ${{ matrix.os }} - permissions: - contents: write - env: - PROJECT: OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} - - - 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@v3 - 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 }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.') || contains(github.ref_name, '-rc9.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.') || contains(github.ref_name, '-rc9.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/package-Instrumentation.AspNet.yml b/.github/workflows/package-Instrumentation.AspNet.yml index 1b90c4dfec..a0aa4af8bc 100644 --- a/.github/workflows/package-Instrumentation.AspNet.yml +++ b/.github/workflows/package-Instrumentation.AspNet.yml @@ -1,5 +1,7 @@ name: Pack OpenTelemetry.Instrumentation.AspNet +# Note: This releases OpenTelemetry.Instrumentation.AspNet & OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule + on: workflow_dispatch: inputs: @@ -9,58 +11,14 @@ on: default: 'warning' push: tags: - - 'Instrumentation.AspNet-*' + - 'Instrumentation.AspNet-*' # trigger when we create a tag with prefix "Instrumentation.AspNet-" jobs: - build-test-pack: - runs-on: ${{ matrix.os }} + call-build-test-pack: permissions: contents: write - env: - PROJECT: OpenTelemetry.Instrumentation.AspNet - - strategy: - matrix: - os: [windows-latest] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # fetching all - - - name: Setup dotnet - uses: actions/setup-dotnet@v3 - - - name: Install dependencies - run: dotnet restore src/${{env.PROJECT}} - - - 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@v3 - 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 }} - - - name: Create GitHub Prerelease - if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.') || contains(github.ref_name, '-rc9.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.') || contains(github.ref_name, '-rc9.')) }} - run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.Instrumentation.AspNet + release-name: 'OpenTelemetry Asp.Net Instrumentation Packages' + secrets: inherit diff --git a/build/Projects/OpenTelemetry.Instrumentation.AspNet.proj b/build/Projects/OpenTelemetry.Instrumentation.AspNet.proj new file mode 100644 index 0000000000..a88fcf404a --- /dev/null +++ b/build/Projects/OpenTelemetry.Instrumentation.AspNet.proj @@ -0,0 +1,30 @@ + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName) + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 94d0778bca..11feb31592 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -45,7 +45,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\package-Extensions.AzureMonitor.yml = .github\workflows\package-Extensions.AzureMonitor.yml .github\workflows\package-Extensions.Docker.yml = .github\workflows\package-Extensions.Docker.yml .github\workflows\package-Extensions.yml = .github\workflows\package-Extensions.yml - .github\workflows\package-Instrumentation.AspNet.TelemetryHttpModule.yml = .github\workflows\package-Instrumentation.AspNet.TelemetryHttpModule.yml .github\workflows\package-Instrumentation.AspNet.yml = .github\workflows\package-Instrumentation.AspNet.yml .github\workflows\package-Instrumentation.AWS.yml = .github\workflows\package-Instrumentation.AWS.yml .github\workflows\package-Instrumentation.AWSLambda.yml = .github\workflows\package-Instrumentation.AWSLambda.yml diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj index 395a6adc25..002e2ffad7 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj @@ -5,7 +5,7 @@ true A module that instruments incoming request with System.Diagnostics.Activity and notifies listeners with DiagnosticsSource. $(PackageTags);distributed-tracing;AspNet;MVC;WebAPI - Instrumentation.AspNet.TelemetryHttpModule- + Instrumentation.AspNet-