From d84f0edf7779fb0afd4e4a80a012abe6edd473cc Mon Sep 17 00:00:00 2001
From: Alan West <3676547+alanwest@users.noreply.github.com>
Date: Tue, 7 Jun 2022 20:46:15 -0700
Subject: [PATCH 1/6] Use DiagnosticSource 7.0 and drop netcoreapp3.1 target
(#3351)
* Remove AspNetCore 3.1 test app
* Remove netcoreapp3.1 target from projects
* Bump to DiagnosticSource 7.0.0-preview.4.22229.4
* Enable CI on net7.0 branch
* Remove trailing space
---
.github/workflows/apicompatibility.yml | 2 +-
.github/workflows/code-coverage.yml | 4 +-
.github/workflows/docfx.yml | 4 +-
.github/workflows/dotnet-format-md.yml | 2 +-
.github/workflows/dotnet-format.yml | 4 +-
.github/workflows/integration-md.yml | 8 +--
.github/workflows/integration.yml | 10 +--
.github/workflows/linux-ci-md.yml | 4 +-
.github/workflows/linux-ci.yml | 6 +-
.github/workflows/markdownlint.yml | 4 +-
.github/workflows/sanitycheck.yml | 4 +-
.github/workflows/windows-ci-md.yml | 4 +-
.github/workflows/windows-ci.yml | 6 +-
OpenTelemetry.sln | 7 --
build/Common.props | 2 +-
docs/Directory.Build.props | 2 +-
.../PublicAPI.Shipped.txt | 0
.../PublicAPI.Unshipped.txt | 0
.../OpenTelemetry.Exporter.Prometheus.csproj | 4 +-
...elemetry.Instrumentation.AspNetCore.csproj | 7 +-
test/Benchmarks/Benchmarks.csproj | 2 +-
...OpenTelemetry.Exporter.Jaeger.Tests.csproj | 2 +-
...xporter.OpenTelemetryProtocol.Tests.csproj | 2 +-
...Telemetry.Exporter.Prometheus.Tests.csproj | 6 +-
...OpenTelemetry.Exporter.ZPages.Tests.csproj | 2 +-
...OpenTelemetry.Exporter.Zipkin.Tests.csproj | 2 +-
...nTelemetry.Extensions.Hosting.Tests.csproj | 2 +-
...emetry.Extensions.Propagators.Tests.csproj | 2 +-
...ry.Instrumentation.AspNetCore.Tests.csproj | 2 +-
...elemetry.Instrumentation.Grpc.Tests.csproj | 2 +-
...elemetry.Instrumentation.Http.Tests.csproj | 2 +-
...try.Instrumentation.SqlClient.Tests.csproj | 2 +-
...strumentation.W3cTraceContext.Tests.csproj | 6 +-
...enTelemetry.Shims.OpenTracing.Tests.csproj | 2 +-
.../OpenTelemetry.Tests.Stress.Metrics.csproj | 2 +-
.../OpenTelemetry.Tests.Stress.csproj | 2 +-
.../OpenTelemetry.Tests.csproj | 2 +-
test/TestApp.AspNetCore.3.1/AssemblyInfo.cs | 24 -------
.../CallbackMiddleware.cs | 48 -------------
.../Controllers/ChildActivityController.cs | 46 ------------
.../Controllers/ForwardController.cs | 71 -------------------
.../Controllers/ValuesController.cs | 56 ---------------
test/TestApp.AspNetCore.3.1/Program.cs | 33 ---------
test/TestApp.AspNetCore.3.1/README.md | 13 ----
test/TestApp.AspNetCore.3.1/Startup.cs | 63 ----------------
.../TestApp.AspNetCore.3.1.csproj | 23 ------
.../appsettings.Development.json | 10 ---
test/TestApp.AspNetCore.3.1/appsettings.json | 15 ----
48 files changed, 53 insertions(+), 475 deletions(-)
rename src/OpenTelemetry.Exporter.Prometheus/.publicApi/{netcoreapp3.1 => net6.0}/PublicAPI.Shipped.txt (100%)
rename src/OpenTelemetry.Exporter.Prometheus/.publicApi/{netcoreapp3.1 => net6.0}/PublicAPI.Unshipped.txt (100%)
delete mode 100644 test/TestApp.AspNetCore.3.1/AssemblyInfo.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/CallbackMiddleware.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/Controllers/ChildActivityController.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/Controllers/ForwardController.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/Controllers/ValuesController.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/Program.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/README.md
delete mode 100644 test/TestApp.AspNetCore.3.1/Startup.cs
delete mode 100644 test/TestApp.AspNetCore.3.1/TestApp.AspNetCore.3.1.csproj
delete mode 100644 test/TestApp.AspNetCore.3.1/appsettings.Development.json
delete mode 100644 test/TestApp.AspNetCore.3.1/appsettings.json
diff --git a/.github/workflows/apicompatibility.yml b/.github/workflows/apicompatibility.yml
index 937d296de..b953fb9ab 100644
--- a/.github/workflows/apicompatibility.yml
+++ b/.github/workflows/apicompatibility.yml
@@ -2,7 +2,7 @@ name: API Compatibility
on:
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml
index 772d8e45a..19edc8ed7 100644
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/code-coverage.yml
@@ -2,11 +2,11 @@ name: Code Coverage
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
diff --git a/.github/workflows/docfx.yml b/.github/workflows/docfx.yml
index b183f8531..9de27064f 100644
--- a/.github/workflows/docfx.yml
+++ b/.github/workflows/docfx.yml
@@ -2,9 +2,9 @@ name: docfx
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
jobs:
build:
diff --git a/.github/workflows/dotnet-format-md.yml b/.github/workflows/dotnet-format-md.yml
index 5453ddca9..6a093eb64 100644
--- a/.github/workflows/dotnet-format-md.yml
+++ b/.github/workflows/dotnet-format-md.yml
@@ -9,7 +9,7 @@ name: dotnet format
on:
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.md'
diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml
index 472fc5f68..ea8666ae6 100644
--- a/.github/workflows/dotnet-format.yml
+++ b/.github/workflows/dotnet-format.yml
@@ -2,12 +2,12 @@ name: dotnet format
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.cs'
- '.editorconfig'
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.cs'
- '.editorconfig'
diff --git a/.github/workflows/integration-md.yml b/.github/workflows/integration-md.yml
index aec19d819..f346041b0 100644
--- a/.github/workflows/integration-md.yml
+++ b/.github/workflows/integration-md.yml
@@ -9,7 +9,7 @@ name: Integration Tests
on:
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.md'
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- run: 'echo "No build required"'
@@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- run: 'echo "No build required"'
@@ -34,6 +34,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- run: 'echo "No build required"'
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index b3d53770e..052e12fff 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -2,11 +2,11 @@ name: Integration Tests
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
@@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- uses: actions/checkout@v3
@@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- uses: actions/checkout@v3
@@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- uses: actions/checkout@v3
diff --git a/.github/workflows/linux-ci-md.yml b/.github/workflows/linux-ci-md.yml
index cec69098e..43975cfaf 100644
--- a/.github/workflows/linux-ci-md.yml
+++ b/.github/workflows/linux-ci-md.yml
@@ -9,7 +9,7 @@ name: Linux
on:
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.md'
@@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- run: 'echo "No build required"'
diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml
index c8fec659c..ae55acfb4 100644
--- a/.github/workflows/linux-ci.yml
+++ b/.github/workflows/linux-ci.yml
@@ -2,11 +2,11 @@ name: Linux
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
@@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
- version: [netcoreapp3.1,net6.0]
+ version: [net6.0]
steps:
- uses: actions/checkout@v3
diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml
index 97f85f9e2..1fbb52e9f 100644
--- a/.github/workflows/markdownlint.yml
+++ b/.github/workflows/markdownlint.yml
@@ -2,11 +2,11 @@ name: markdownlint
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.md'
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.md'
diff --git a/.github/workflows/sanitycheck.yml b/.github/workflows/sanitycheck.yml
index a52563198..ef2e5cd14 100644
--- a/.github/workflows/sanitycheck.yml
+++ b/.github/workflows/sanitycheck.yml
@@ -2,9 +2,9 @@ name: sanitycheck
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
jobs:
misspell:
diff --git a/.github/workflows/windows-ci-md.yml b/.github/workflows/windows-ci-md.yml
index 2e2bfd561..1b409793a 100644
--- a/.github/workflows/windows-ci-md.yml
+++ b/.github/workflows/windows-ci-md.yml
@@ -9,7 +9,7 @@ name: Windows
on:
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths:
- '**.md'
@@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
- version: [net462,netcoreapp3.1,net6.0]
+ version: [net462,net6.0]
steps:
- run: 'echo "No build required"'
diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml
index 9996cd8ea..45f7783f0 100644
--- a/.github/workflows/windows-ci.yml
+++ b/.github/workflows/windows-ci.yml
@@ -2,11 +2,11 @@ name: Windows
on:
push:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
pull_request:
- branches: [ main ]
+ branches: [ main, net7.0 ]
paths-ignore:
- '**.md'
@@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
- version: [net462,netcoreapp3.1,net6.0]
+ version: [net462,net6.0]
steps:
- uses: actions/checkout@v3
diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln
index e74cd2724..b15e5d2b0 100644
--- a/OpenTelemetry.sln
+++ b/OpenTelemetry.sln
@@ -50,8 +50,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentati
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testdata", "testdata", "{77C7929A-2EED-4AA6-8705-B5C443C8AA0F}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.3.1", "test\TestApp.AspNetCore.3.1\TestApp.AspNetCore.3.1.csproj", "{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{E359BB2B-9AEC-497D-B321-7DF2450C3B8E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Jaeger", "src\OpenTelemetry.Exporter.Jaeger\OpenTelemetry.Exporter.Jaeger.csproj", "{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}"
@@ -266,10 +264,6 @@ Global
{2A47F6A8-63E5-4237-8046-94CAF321E797}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A47F6A8-63E5-4237-8046-94CAF321E797}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A47F6A8-63E5-4237-8046-94CAF321E797}.Release|Any CPU.Build.0 = Release|Any CPU
- {F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Release|Any CPU.Build.0 = Release|Any CPU
{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D47E3CF-9AE3-42FE-9084-FEB72D9AD769}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -491,7 +485,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {F2F81E76-6A0E-466B-B673-EBBF1A9ED075} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
{A533C800-3DC3-4D04-90A7-0CE7A1E6BDB3} = {F1D0972B-38CF-49C2-9F4B-4C5DE02FB71D}
{E69578EB-B456-4062-A645-877CD964528B} = {F1D0972B-38CF-49C2-9F4B-4C5DE02FB71D}
{C1542297-8763-4DF4-957C-489ED771C21D} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
diff --git a/build/Common.props b/build/Common.props
index b512b98b5..f1c8471b4 100644
--- a/build/Common.props
+++ b/build/Common.props
@@ -42,7 +42,7 @@
1.3.0
[1.2.0-beta.354,2.0)
1.4.0
- 6.0.0
+ 7.0.0-preview.4.22229.4
4.7.0
4.7.0
4.5.3
diff --git a/docs/Directory.Build.props b/docs/Directory.Build.props
index 66de93982..9d8626a31 100644
--- a/docs/Directory.Build.props
+++ b/docs/Directory.Build.props
@@ -5,7 +5,7 @@
Exe
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462;net47;net471;net472;net48
diff --git a/src/OpenTelemetry.Exporter.Prometheus/.publicApi/netcoreapp3.1/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Prometheus/.publicApi/net6.0/PublicAPI.Shipped.txt
similarity index 100%
rename from src/OpenTelemetry.Exporter.Prometheus/.publicApi/netcoreapp3.1/PublicAPI.Shipped.txt
rename to src/OpenTelemetry.Exporter.Prometheus/.publicApi/net6.0/PublicAPI.Shipped.txt
diff --git a/src/OpenTelemetry.Exporter.Prometheus/.publicApi/netcoreapp3.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Prometheus/.publicApi/net6.0/PublicAPI.Unshipped.txt
similarity index 100%
rename from src/OpenTelemetry.Exporter.Prometheus/.publicApi/netcoreapp3.1/PublicAPI.Unshipped.txt
rename to src/OpenTelemetry.Exporter.Prometheus/.publicApi/net6.0/PublicAPI.Unshipped.txt
diff --git a/src/OpenTelemetry.Exporter.Prometheus/OpenTelemetry.Exporter.Prometheus.csproj b/src/OpenTelemetry.Exporter.Prometheus/OpenTelemetry.Exporter.Prometheus.csproj
index c53448ea4..526089a32 100644
--- a/src/OpenTelemetry.Exporter.Prometheus/OpenTelemetry.Exporter.Prometheus.csproj
+++ b/src/OpenTelemetry.Exporter.Prometheus/OpenTelemetry.Exporter.Prometheus.csproj
@@ -2,7 +2,7 @@
- netcoreapp3.1;net462
+ net6.0;net462
Prometheus exporter for OpenTelemetry .NET
$(PackageTags);prometheus;metrics
core-
@@ -27,7 +27,7 @@
-
+
diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj b/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj
index 82732cdb5..26335806a 100644
--- a/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj
+++ b/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj
@@ -1,7 +1,7 @@
- net6.0;netcoreapp3.1;netstandard2.1;netstandard2.0
+ net6.0;netstandard2.1;netstandard2.0
ASP.NET Core instrumentation for OpenTelemetry .NET
$(PackageTags);distributed-tracing;AspNetCore
true
@@ -28,11 +28,6 @@
-
-
-
-
-
diff --git a/test/Benchmarks/Benchmarks.csproj b/test/Benchmarks/Benchmarks.csproj
index 12e759d9f..f488c7c29 100644
--- a/test/Benchmarks/Benchmarks.csproj
+++ b/test/Benchmarks/Benchmarks.csproj
@@ -3,7 +3,7 @@
Exe
- net6.0;netcoreapp3.1;net462
+ net6.0;net462
false
diff --git a/test/OpenTelemetry.Exporter.Jaeger.Tests/OpenTelemetry.Exporter.Jaeger.Tests.csproj b/test/OpenTelemetry.Exporter.Jaeger.Tests/OpenTelemetry.Exporter.Jaeger.Tests.csproj
index 01ea3dce4..32705554e 100644
--- a/test/OpenTelemetry.Exporter.Jaeger.Tests/OpenTelemetry.Exporter.Jaeger.Tests.csproj
+++ b/test/OpenTelemetry.Exporter.Jaeger.Tests/OpenTelemetry.Exporter.Jaeger.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for Jaeger Exporter for OpenTelemetry
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
false
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj
index bc0829061..95b2de799 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj
@@ -2,7 +2,7 @@
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
$(TARGET_FRAMEWORK)
false
diff --git a/test/OpenTelemetry.Exporter.Prometheus.Tests/OpenTelemetry.Exporter.Prometheus.Tests.csproj b/test/OpenTelemetry.Exporter.Prometheus.Tests/OpenTelemetry.Exporter.Prometheus.Tests.csproj
index e3ff74aba..9d8b6e138 100644
--- a/test/OpenTelemetry.Exporter.Prometheus.Tests/OpenTelemetry.Exporter.Prometheus.Tests.csproj
+++ b/test/OpenTelemetry.Exporter.Prometheus.Tests/OpenTelemetry.Exporter.Prometheus.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for Prometheus Exporter for OpenTelemetry
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
false
@@ -29,10 +29,6 @@
-
-
-
-
diff --git a/test/OpenTelemetry.Exporter.ZPages.Tests/OpenTelemetry.Exporter.ZPages.Tests.csproj b/test/OpenTelemetry.Exporter.ZPages.Tests/OpenTelemetry.Exporter.ZPages.Tests.csproj
index 46a3ef710..6fad21338 100644
--- a/test/OpenTelemetry.Exporter.ZPages.Tests/OpenTelemetry.Exporter.ZPages.Tests.csproj
+++ b/test/OpenTelemetry.Exporter.ZPages.Tests/OpenTelemetry.Exporter.ZPages.Tests.csproj
@@ -2,7 +2,7 @@
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
false
diff --git a/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj b/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj
index ffadcae75..84e82aec2 100644
--- a/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj
+++ b/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for Zipkin Exporter for OpenTelemetry
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
false
diff --git a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj
index 95b8de049..a17774b6b 100644
--- a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj
+++ b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry .NET Core hosting library
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
diff --git a/test/OpenTelemetry.Extensions.Propagators.Tests/OpenTelemetry.Extensions.Propagators.Tests.csproj b/test/OpenTelemetry.Extensions.Propagators.Tests/OpenTelemetry.Extensions.Propagators.Tests.csproj
index 9186da7a9..485184b25 100644
--- a/test/OpenTelemetry.Extensions.Propagators.Tests/OpenTelemetry.Extensions.Propagators.Tests.csproj
+++ b/test/OpenTelemetry.Extensions.Propagators.Tests/OpenTelemetry.Extensions.Propagators.Tests.csproj
@@ -2,7 +2,7 @@
- net6.0;netcoreapp3.1;net462
+ net6.0;net462
$(TARGET_FRAMEWORK)
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj
index 003cf214a..b4376a0a3 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry ASP.NET Core instrumentation
- net6.0;netcoreapp3.1
+ net6.0
diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/OpenTelemetry.Instrumentation.Grpc.Tests.csproj b/test/OpenTelemetry.Instrumentation.Grpc.Tests/OpenTelemetry.Instrumentation.Grpc.Tests.csproj
index 119c38e28..f780997f3 100644
--- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/OpenTelemetry.Instrumentation.Grpc.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/OpenTelemetry.Instrumentation.Grpc.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry Grpc for .NET instrumentation
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj b/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj
index a38f1a99c..f5e6fdd3e 100644
--- a/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry HTTP instrumentations
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj
index 8a9353c97..7f3f224f3 100644
--- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry SqlClient instrumentations
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
$(TARGET_FRAMEWORK)
diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj
index de4eeeff8..d410a3bf3 100644
--- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj
@@ -3,7 +3,7 @@
Unit test project for OpenTelemetry ASP.NET Core instrumentation for W3C Trace Context Trace
- net6.0;netcoreapp3.1
+ net6.0
$(TARGET_FRAMEWORK)
@@ -33,10 +33,6 @@
-
-
-
-
diff --git a/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj b/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj
index 478fc22c7..3367474db 100644
--- a/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj
+++ b/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry.Shims.OpenTracing
- net6.0;netcoreapp3.1
+ net6.0
diff --git a/test/OpenTelemetry.Tests.Stress.Metrics/OpenTelemetry.Tests.Stress.Metrics.csproj b/test/OpenTelemetry.Tests.Stress.Metrics/OpenTelemetry.Tests.Stress.Metrics.csproj
index 97d1f4382..467e98c07 100644
--- a/test/OpenTelemetry.Tests.Stress.Metrics/OpenTelemetry.Tests.Stress.Metrics.csproj
+++ b/test/OpenTelemetry.Tests.Stress.Metrics/OpenTelemetry.Tests.Stress.Metrics.csproj
@@ -3,7 +3,7 @@
Exe
- net6.0;netcoreapp3.1;net462
+ net6.0;net462
false
diff --git a/test/OpenTelemetry.Tests.Stress/OpenTelemetry.Tests.Stress.csproj b/test/OpenTelemetry.Tests.Stress/OpenTelemetry.Tests.Stress.csproj
index 31166433f..93013144b 100644
--- a/test/OpenTelemetry.Tests.Stress/OpenTelemetry.Tests.Stress.csproj
+++ b/test/OpenTelemetry.Tests.Stress/OpenTelemetry.Tests.Stress.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0;netcoreapp3.1;net462
+ net6.0;net462
false
diff --git a/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj b/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj
index 8d1c69f4f..199db4b6e 100644
--- a/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj
+++ b/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry
- net6.0;netcoreapp3.1
+ net6.0
$(TargetFrameworks);net462
$(NoWarn),CS0618
diff --git a/test/TestApp.AspNetCore.3.1/AssemblyInfo.cs b/test/TestApp.AspNetCore.3.1/AssemblyInfo.cs
deleted file mode 100644
index a7d6eb86a..000000000
--- a/test/TestApp.AspNetCore.3.1/AssemblyInfo.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// 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.
-//
-
-using System.Diagnostics.CodeAnalysis;
-
-[assembly: SuppressMessage(
- "StyleCop.CSharp.NamingRules",
- "SA1300",
- Justification = "Reviewed.",
- Scope = "namespaceanddescendants",
- Target = "TestApp.AspNetCore._3._1")]
diff --git a/test/TestApp.AspNetCore.3.1/CallbackMiddleware.cs b/test/TestApp.AspNetCore.3.1/CallbackMiddleware.cs
deleted file mode 100644
index 97023ac6c..000000000
--- a/test/TestApp.AspNetCore.3.1/CallbackMiddleware.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// 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.
-//
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
-
-namespace TestApp.AspNetCore._3._1
-{
- public class CallbackMiddleware
- {
- private readonly CallbackMiddlewareImpl impl;
- private readonly RequestDelegate next;
-
- public CallbackMiddleware(RequestDelegate next, CallbackMiddlewareImpl impl)
- {
- this.next = next;
- this.impl = impl;
- }
-
- public async Task InvokeAsync(HttpContext context)
- {
- if (this.impl == null || await this.impl.ProcessAsync(context))
- {
- await this.next(context);
- }
- }
-
- public class CallbackMiddlewareImpl
- {
- public virtual async Task ProcessAsync(HttpContext context)
- {
- return await Task.FromResult(true);
- }
- }
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/Controllers/ChildActivityController.cs b/test/TestApp.AspNetCore.3.1/Controllers/ChildActivityController.cs
deleted file mode 100644
index 911f9bae6..000000000
--- a/test/TestApp.AspNetCore.3.1/Controllers/ChildActivityController.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// 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.
-//
-
-using System.Collections.Generic;
-using System.Diagnostics;
-using Microsoft.AspNetCore.Mvc;
-using OpenTelemetry;
-
-namespace TestApp.AspNetCore._3._1.Controllers
-{
- public class ChildActivityController : Controller
- {
- [Route("api/GetChildActivityTraceContext")]
- public Dictionary GetChildActivityTraceContext()
- {
- var result = new Dictionary();
- var activity = new Activity("ActivityInsideHttpRequest");
- activity.Start();
- result["TraceId"] = activity.Context.TraceId.ToString();
- result["ParentSpanId"] = activity.ParentSpanId.ToString();
- result["TraceState"] = activity.Context.TraceState;
- activity.Stop();
- return result;
- }
-
- [Route("api/GetChildActivityBaggageContext")]
- public IReadOnlyDictionary GetChildActivityBaggageContext()
- {
- var result = Baggage.Current.GetBaggage();
- return result;
- }
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/Controllers/ForwardController.cs b/test/TestApp.AspNetCore.3.1/Controllers/ForwardController.cs
deleted file mode 100644
index 31b98f695..000000000
--- a/test/TestApp.AspNetCore.3.1/Controllers/ForwardController.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// 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.
-//
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using Newtonsoft.Json;
-
-namespace TestApp.AspNetCore._3._1.Controllers
-{
- [Route("api/[controller]")]
- public class ForwardController : Controller
- {
- private readonly HttpClient httpClient;
-
- public ForwardController(HttpClient httpClient)
- {
- this.httpClient = httpClient;
- }
-
- // POST api/test
- [HttpPost]
- public async Task Post([FromBody] Data[] data)
- {
- var result = string.Empty;
-
- if (data != null)
- {
- foreach (var argument in data)
- {
- var request = new HttpRequestMessage(HttpMethod.Post, argument.Url)
- {
- Content = new StringContent(
- JsonConvert.SerializeObject(argument.Arguments),
- Encoding.UTF8,
- "application/json"),
- };
- await this.httpClient.SendAsync(request);
- }
- }
- else
- {
- result = "done";
- }
-
- return result;
- }
-
- public class Data
- {
- [JsonProperty("url")]
- public string Url { get; set; }
-
- [JsonProperty("arguments")]
- public Data[] Arguments { get; set; }
- }
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/Controllers/ValuesController.cs b/test/TestApp.AspNetCore.3.1/Controllers/ValuesController.cs
deleted file mode 100644
index c7143faec..000000000
--- a/test/TestApp.AspNetCore.3.1/Controllers/ValuesController.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// 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.
-//
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Mvc;
-
-namespace TestApp.AspNetCore._3._1.Controllers
-{
- [Route("api/[controller]")]
- public class ValuesController : Controller
- {
- // GET api/values
- [HttpGet]
- public IEnumerable Get()
- {
- return new string[] { "value1", "value2" };
- }
-
- // GET api/values/5
- [HttpGet("{id}")]
- public string Get(int id)
- {
- return "value";
- }
-
- // POST api/values
- [HttpPost]
- public void Post([FromBody] string value)
- {
- }
-
- // PUT api/values/5
- [HttpPut("{id}")]
- public void Put(int id, [FromBody] string value)
- {
- }
-
- // DELETE api/values/5
- [HttpDelete("{id}")]
- public void Delete(int id)
- {
- }
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/Program.cs b/test/TestApp.AspNetCore.3.1/Program.cs
deleted file mode 100644
index 44e9398c0..000000000
--- a/test/TestApp.AspNetCore.3.1/Program.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// 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.
-//
-
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
-
-namespace TestApp.AspNetCore._3._1
-{
- public class Program
- {
- public static void Main(string[] args)
- {
- CreateWebHostBuilder(args).Build().Run();
- }
-
- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseStartup();
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/README.md b/test/TestApp.AspNetCore.3.1/README.md
deleted file mode 100644
index db05b30cc..000000000
--- a/test/TestApp.AspNetCore.3.1/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# ASP.NET Core Integration Test
-
-This test app is used for ASP.NET Core integration testing by unit tests. You
-could also manually run W3C test suite.
-
-## Run W3C test suite
-
-The detailed instruction for the test tool available
-[here](https://github.com/w3c/trace-context/tree/master/test).
-
-* Follow it to install prerequisites and get the test code
-* Start this test app with Visual Studio (or `dotnet run`)
-* Run test per instruction using `http://localhost:63741/api/forward` endpoint
diff --git a/test/TestApp.AspNetCore.3.1/Startup.cs b/test/TestApp.AspNetCore.3.1/Startup.cs
deleted file mode 100644
index eaf926c8a..000000000
--- a/test/TestApp.AspNetCore.3.1/Startup.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//
-// 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.
-//
-
-using System.Net.Http;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-
-namespace TestApp.AspNetCore._3._1
-{
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- this.Configuration = configuration;
- }
-
- public IConfiguration Configuration { get; }
-
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddMvc();
- services.AddSingleton();
- services.AddSingleton(
- new CallbackMiddleware.CallbackMiddlewareImpl());
- }
-
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
-
- app.UseMiddleware();
- app.UseRouting();
-
- app.UseAuthorization();
-
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- }
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/TestApp.AspNetCore.3.1.csproj b/test/TestApp.AspNetCore.3.1/TestApp.AspNetCore.3.1.csproj
deleted file mode 100644
index 6dae1f7c3..000000000
--- a/test/TestApp.AspNetCore.3.1/TestApp.AspNetCore.3.1.csproj
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- netcoreapp3.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/test/TestApp.AspNetCore.3.1/appsettings.Development.json b/test/TestApp.AspNetCore.3.1/appsettings.Development.json
deleted file mode 100644
index fa8ce71a9..000000000
--- a/test/TestApp.AspNetCore.3.1/appsettings.Development.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "Logging": {
- "IncludeScopes": false,
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
- }
-}
diff --git a/test/TestApp.AspNetCore.3.1/appsettings.json b/test/TestApp.AspNetCore.3.1/appsettings.json
deleted file mode 100644
index 26bb0ac7a..000000000
--- a/test/TestApp.AspNetCore.3.1/appsettings.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "Logging": {
- "IncludeScopes": false,
- "Debug": {
- "LogLevel": {
- "Default": "Warning"
- }
- },
- "Console": {
- "LogLevel": {
- "Default": "Warning"
- }
- }
- }
-}
From 5d5f1f29642847cac37f89bb0d807194c695f35d Mon Sep 17 00:00:00 2001
From: Vishwesh Bankwar
Date: Fri, 17 Jun 2022 10:27:18 -0700
Subject: [PATCH 2/6] Add net7.0 target for aspnetcore (#3366)
---
.github/workflows/apicompatibility.yml | 6 ++
.github/workflows/code-coverage.yml | 6 ++
.github/workflows/dotnet-format.yml | 6 ++
.github/workflows/linux-ci.yml | 12 ++-
.github/workflows/windows-ci.yml | 10 ++-
global.json | 3 +-
.../.publicApi/net7.0/PublicAPI.Shipped.txt | 0
.../.publicApi/net7.0/PublicAPI.Unshipped.txt | 14 ++++
...elemetry.Instrumentation.AspNetCore.csproj | 6 +-
.../BasicTests.cs | 3 +
.../DependencyInjectionConfigTests.cs | 3 +
...stsCollectionsIsAccordingToTheSpecTests.cs | 3 +
.../MetricTests.cs | 3 +
...ry.Instrumentation.AspNetCore.Tests.csproj | 7 +-
.../Dockerfile | 6 +-
test/TestApp.AspNetCore.7.0/AssemblyInfo.cs | 24 ++++++
.../CallbackMiddleware.cs | 51 +++++++++++++
.../Controllers/ChildActivityController.cs | 48 ++++++++++++
.../Controllers/ForwardController.cs | 74 +++++++++++++++++++
.../Controllers/ValuesController.cs | 58 +++++++++++++++
test/TestApp.AspNetCore.7.0/Program.cs | 35 +++++++++
test/TestApp.AspNetCore.7.0/Startup.cs | 65 ++++++++++++++++
.../TestApp.AspNetCore.7.0.csproj | 25 +++++++
.../appsettings.Development.json | 10 +++
test/TestApp.AspNetCore.7.0/appsettings.json | 15 ++++
25 files changed, 485 insertions(+), 8 deletions(-)
create mode 100644 src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Shipped.txt
create mode 100644 src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt
create mode 100644 test/TestApp.AspNetCore.7.0/AssemblyInfo.cs
create mode 100644 test/TestApp.AspNetCore.7.0/CallbackMiddleware.cs
create mode 100644 test/TestApp.AspNetCore.7.0/Controllers/ChildActivityController.cs
create mode 100644 test/TestApp.AspNetCore.7.0/Controllers/ForwardController.cs
create mode 100644 test/TestApp.AspNetCore.7.0/Controllers/ValuesController.cs
create mode 100644 test/TestApp.AspNetCore.7.0/Program.cs
create mode 100644 test/TestApp.AspNetCore.7.0/Startup.cs
create mode 100644 test/TestApp.AspNetCore.7.0/TestApp.AspNetCore.7.0.csproj
create mode 100644 test/TestApp.AspNetCore.7.0/appsettings.Development.json
create mode 100644 test/TestApp.AspNetCore.7.0/appsettings.json
diff --git a/.github/workflows/apicompatibility.yml b/.github/workflows/apicompatibility.yml
index b953fb9ab..5a948df11 100644
--- a/.github/workflows/apicompatibility.yml
+++ b/.github/workflows/apicompatibility.yml
@@ -11,8 +11,14 @@ jobs:
runs-on: windows-latest
env:
CheckAPICompatibility: true
+ # https://github.com/actions/setup-dotnet/issues/122
+ DOTNET_MULTILEVEL_LOOKUP: 1
steps:
- uses: actions/checkout@v3
+ - uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '7.0.x'
+ include-prerelease: true
- name: Install dependencies
run: dotnet restore
diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml
index 19edc8ed7..deedcf1f8 100644
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/code-coverage.yml
@@ -20,11 +20,17 @@ jobs:
os: [windows-latest]
env:
OS: ${{ matrix.os }}
+ # https://github.com/actions/setup-dotnet/issues/122
+ DOTNET_MULTILEVEL_LOOKUP: 1
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetching all
+ - uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '7.0.x'
+ include-prerelease: true
- name: Install dependencies
run: dotnet restore
diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml
index ea8666ae6..f88e0613d 100644
--- a/.github/workflows/dotnet-format.yml
+++ b/.github/workflows/dotnet-format.yml
@@ -25,6 +25,12 @@ jobs:
with:
dotnet-version: 6.0.x
+ - name: Setup .NET Core 7.0
+ - uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '7.0.x'
+ include-prerelease: true
+
- name: Install format tool
run: dotnet tool install -g dotnet-format
diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml
index ae55acfb4..52e0bc9f2 100644
--- a/.github/workflows/linux-ci.yml
+++ b/.github/workflows/linux-ci.yml
@@ -16,11 +16,21 @@ jobs:
strategy:
matrix:
- version: [net6.0]
+ version: [net6.0, net7.0]
steps:
- uses: actions/checkout@v3
+ - uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '6.0.x'
+
+ - uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '7.0.x'
+ include-prerelease: true
+
+
- name: Install dependencies
run: dotnet restore
diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml
index 45f7783f0..a9ff3f3f3 100644
--- a/.github/workflows/windows-ci.yml
+++ b/.github/workflows/windows-ci.yml
@@ -13,14 +13,22 @@ on:
jobs:
build-test:
runs-on: windows-latest
+ env:
+ # https://github.com/actions/setup-dotnet/issues/122
+ DOTNET_MULTILEVEL_LOOKUP: 1
strategy:
matrix:
- version: [net462,net6.0]
+ version: [net462,net6.0,net7.0]
steps:
- uses: actions/checkout@v3
+ - uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '7.0.x'
+ include-prerelease: true
+
- name: Install dependencies
run: dotnet restore
diff --git a/global.json b/global.json
index 69fd35842..31ef06538 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,7 @@
{
"sdk": {
"rollForward": "latestFeature",
- "version": "6.0.100"
+ "version": "6.0.100",
+ "allowPrerelease": "true"
}
}
diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Shipped.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt
new file mode 100644
index 000000000..87d29939c
--- /dev/null
+++ b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt
@@ -0,0 +1,14 @@
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.AspNetCoreInstrumentationOptions() -> void
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.get -> bool
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.set -> void
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Enrich.get -> System.Action
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Enrich.set -> void
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.get -> System.Func
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.Filter.set -> void
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.get -> bool
+OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.RecordException.set -> void
+OpenTelemetry.Metrics.MeterProviderBuilderExtensions
+OpenTelemetry.Trace.TracerProviderBuilderExtensions
+static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder
+static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configureAspNetCoreInstrumentationOptions = null) -> OpenTelemetry.Trace.TracerProviderBuilder
\ No newline at end of file
diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj b/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj
index 26335806a..39a747538 100644
--- a/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj
+++ b/src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj
@@ -1,7 +1,7 @@
- net6.0;netstandard2.1;netstandard2.0
+ net7.0;net6.0;netstandard2.1;netstandard2.0
ASP.NET Core instrumentation for OpenTelemetry .NET
$(PackageTags);distributed-tracing;AspNetCore
true
@@ -32,4 +32,8 @@
+
+
+
+
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
index 03dc2b9d6..21eaa64a3 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
@@ -38,6 +38,9 @@ using TestApp.AspNetCore._3._1;
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
+#if NET7_0
+using TestApp.AspNetCore._7._0;
+#endif
using Xunit;
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs
index 7706854e7..eabe0e600 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs
@@ -24,6 +24,9 @@ using TestApp.AspNetCore._3._1;
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
+#if NET7_0
+using TestApp.AspNetCore._7._0;
+#endif
using Xunit;
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs
index 84927ed7e..fc6825532 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs
@@ -31,6 +31,9 @@ using TestApp.AspNetCore._3._1;
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
+#if NET7_0
+using TestApp.AspNetCore._7._0;
+#endif
using Xunit;
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs
index 925122306..9dfb1f1db 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs
@@ -27,6 +27,9 @@ using TestApp.AspNetCore._3._1;
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
+#if NET7_0
+using TestApp.AspNetCore._7._0;
+#endif
using Xunit;
namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj
index b4376a0a3..9d76e241a 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/OpenTelemetry.Instrumentation.AspNetCore.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry ASP.NET Core instrumentation
- net6.0
+ net7.0;net6.0
@@ -27,6 +27,11 @@
+
+
+
+
+
diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile
index cacdd48cc..5698ff755 100644
--- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile
+++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile
@@ -2,16 +2,16 @@
# This should be run from the root of the repo:
# docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile .
-ARG SDK_VERSION=6.0
+ARG SDK_VERSION=7.0
FROM ubuntu AS w3c
#Install git
WORKDIR /w3c
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/w3c/trace-context.git
-FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
+FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
ARG PUBLISH_CONFIGURATION=Release
-ARG PUBLISH_FRAMEWORK=net6.0
+ARG PUBLISH_FRAMEWORK=net7.0
WORKDIR /repo
COPY . ./
WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests"
diff --git a/test/TestApp.AspNetCore.7.0/AssemblyInfo.cs b/test/TestApp.AspNetCore.7.0/AssemblyInfo.cs
new file mode 100644
index 000000000..e953a8003
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/AssemblyInfo.cs
@@ -0,0 +1,24 @@
+//
+// 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.
+//
+
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage(
+ "StyleCop.CSharp.NamingRules",
+ "SA1300",
+ Justification = "Reviewed.",
+ Scope = "namespaceanddescendants",
+ Target = "TestApp.AspNetCore._6._0")]
diff --git a/test/TestApp.AspNetCore.7.0/CallbackMiddleware.cs b/test/TestApp.AspNetCore.7.0/CallbackMiddleware.cs
new file mode 100644
index 000000000..a6609b393
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/CallbackMiddleware.cs
@@ -0,0 +1,51 @@
+//
+// 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.
+//
+
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+
+#pragma warning disable SA1300 // Element should begin with upper-case letter
+namespace TestApp.AspNetCore._7._0
+#pragma warning restore SA1300 // Element should begin with upper-case letter
+{
+ public class CallbackMiddleware
+ {
+ private readonly CallbackMiddlewareImpl impl;
+ private readonly RequestDelegate next;
+
+ public CallbackMiddleware(RequestDelegate next, CallbackMiddlewareImpl impl)
+ {
+ this.next = next;
+ this.impl = impl;
+ }
+
+ public async Task InvokeAsync(HttpContext context)
+ {
+ if (this.impl == null || await this.impl.ProcessAsync(context))
+ {
+ await this.next(context);
+ }
+ }
+
+ public class CallbackMiddlewareImpl
+ {
+ public virtual async Task ProcessAsync(HttpContext context)
+ {
+ return await Task.FromResult(true);
+ }
+ }
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/Controllers/ChildActivityController.cs b/test/TestApp.AspNetCore.7.0/Controllers/ChildActivityController.cs
new file mode 100644
index 000000000..a31e42a86
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/Controllers/ChildActivityController.cs
@@ -0,0 +1,48 @@
+//
+// 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.
+//
+
+using System.Collections.Generic;
+using System.Diagnostics;
+using Microsoft.AspNetCore.Mvc;
+using OpenTelemetry;
+
+#pragma warning disable SA1300 // Element should begin with upper-case letter
+namespace TestApp.AspNetCore._7._0.Controllers
+#pragma warning restore SA1300 // Element should begin with upper-case letter
+{
+ public class ChildActivityController : Controller
+ {
+ [Route("api/GetChildActivityTraceContext")]
+ public Dictionary GetChildActivityTraceContext()
+ {
+ var result = new Dictionary();
+ var activity = new Activity("ActivityInsideHttpRequest");
+ activity.Start();
+ result["TraceId"] = activity.Context.TraceId.ToString();
+ result["ParentSpanId"] = activity.ParentSpanId.ToString();
+ result["TraceState"] = activity.Context.TraceState;
+ activity.Stop();
+ return result;
+ }
+
+ [Route("api/GetChildActivityBaggageContext")]
+ public IReadOnlyDictionary GetChildActivityBaggageContext()
+ {
+ var result = Baggage.Current.GetBaggage();
+ return result;
+ }
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/Controllers/ForwardController.cs b/test/TestApp.AspNetCore.7.0/Controllers/ForwardController.cs
new file mode 100644
index 000000000..ebdc5f062
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/Controllers/ForwardController.cs
@@ -0,0 +1,74 @@
+//
+// 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.
+//
+
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json;
+
+#pragma warning disable SA1300 // Element should begin with upper-case letter
+namespace TestApp.AspNetCore._7._0.Controllers
+#pragma warning restore SA1300 // Element should begin with upper-case letter
+{
+ [Route("api/[controller]")]
+ public class ForwardController : Controller
+ {
+ private readonly HttpClient httpClient;
+
+ public ForwardController(HttpClient httpClient)
+ {
+ this.httpClient = httpClient;
+ }
+
+ // POST api/test
+ [HttpPost]
+ public async Task Post([FromBody] Data[] data)
+ {
+ var result = string.Empty;
+
+ if (data != null)
+ {
+ foreach (var argument in data)
+ {
+ var request = new HttpRequestMessage(HttpMethod.Post, argument.Url)
+ {
+ Content = new StringContent(
+ JsonConvert.SerializeObject(argument.Arguments),
+ Encoding.UTF8,
+ "application/json"),
+ };
+ await this.httpClient.SendAsync(request);
+ }
+ }
+ else
+ {
+ result = "done";
+ }
+
+ return result;
+ }
+
+ public class Data
+ {
+ [JsonProperty("url")]
+ public string Url { get; set; }
+
+ [JsonProperty("arguments")]
+ public Data[] Arguments { get; set; }
+ }
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/Controllers/ValuesController.cs b/test/TestApp.AspNetCore.7.0/Controllers/ValuesController.cs
new file mode 100644
index 000000000..0183988b6
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/Controllers/ValuesController.cs
@@ -0,0 +1,58 @@
+//
+// 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.
+//
+using System.Collections.Generic;
+using Microsoft.AspNetCore.Mvc;
+
+#pragma warning disable SA1300 // Element should begin with upper-case letter
+namespace TestApp.AspNetCore._7._0.Controllers
+#pragma warning restore SA1300 // Element should begin with upper-case letter
+{
+ [Route("api/[controller]")]
+ public class ValuesController : Controller
+ {
+ // GET api/values
+ [HttpGet]
+ public IEnumerable Get()
+ {
+ return new string[] { "value1", "value2" };
+ }
+
+ // GET api/values/5
+ [HttpGet("{id}")]
+ public string Get(int id)
+ {
+ return "value";
+ }
+
+ // POST api/values
+ [HttpPost]
+ public void Post([FromBody] string value)
+ {
+ }
+
+ // PUT api/values/5
+ [HttpPut("{id}")]
+ public void Put(int id, [FromBody] string value)
+ {
+ }
+
+ // DELETE api/values/5
+ [HttpDelete("{id}")]
+ public void Delete(int id)
+ {
+ }
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/Program.cs b/test/TestApp.AspNetCore.7.0/Program.cs
new file mode 100644
index 000000000..bdf1d8b72
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/Program.cs
@@ -0,0 +1,35 @@
+//
+// 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.
+//
+
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+
+#pragma warning disable SA1300 // Element should begin with upper-case letter
+namespace TestApp.AspNetCore._7._0
+#pragma warning restore SA1300 // Element should begin with upper-case letter
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateWebHostBuilder(args).Build().Run();
+ }
+
+ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
+ WebHost.CreateDefaultBuilder(args)
+ .UseStartup();
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/Startup.cs b/test/TestApp.AspNetCore.7.0/Startup.cs
new file mode 100644
index 000000000..47bb7ac8d
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/Startup.cs
@@ -0,0 +1,65 @@
+//
+// 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.
+//
+
+using System.Net.Http;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+
+#pragma warning disable SA1300 // Element should begin with upper-case letter
+namespace TestApp.AspNetCore._7._0
+#pragma warning restore SA1300 // Element should begin with upper-case letter
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ this.Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddMvc();
+ services.AddSingleton();
+ services.AddSingleton(
+ new CallbackMiddleware.CallbackMiddlewareImpl());
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+
+ app.UseMiddleware();
+ app.UseRouting();
+
+ app.UseAuthorization();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers();
+ });
+ }
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/TestApp.AspNetCore.7.0.csproj b/test/TestApp.AspNetCore.7.0/TestApp.AspNetCore.7.0.csproj
new file mode 100644
index 000000000..ef7445dd1
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/TestApp.AspNetCore.7.0.csproj
@@ -0,0 +1,25 @@
+
+
+
+ net7.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/TestApp.AspNetCore.7.0/appsettings.Development.json b/test/TestApp.AspNetCore.7.0/appsettings.Development.json
new file mode 100644
index 000000000..fa8ce71a9
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/appsettings.Development.json
@@ -0,0 +1,10 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ }
+}
diff --git a/test/TestApp.AspNetCore.7.0/appsettings.json b/test/TestApp.AspNetCore.7.0/appsettings.json
new file mode 100644
index 000000000..26bb0ac7a
--- /dev/null
+++ b/test/TestApp.AspNetCore.7.0/appsettings.json
@@ -0,0 +1,15 @@
+{
+ "Logging": {
+ "IncludeScopes": false,
+ "Debug": {
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ },
+ "Console": {
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ }
+ }
+}
From 6c9dc8e2b379ea6c5f13e2d5f01affe15384cb22 Mon Sep 17 00:00:00 2001
From: Vishwesh Bankwar
Date: Mon, 20 Jun 2022 11:29:00 -0700
Subject: [PATCH 3/6] [.NET7.0] Add net7.0 target to w3c trace contexts (#3390)
* Add net7.0 target for w3ctracecontext tests
* net70 dependency
* fix typo
---
.../InProcessServer.cs | 3 +++
...enTelemetry.Instrumentation.W3cTraceContext.Tests.csproj | 6 +++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/InProcessServer.cs b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/InProcessServer.cs
index 62e544fd2..9cb29488d 100644
--- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/InProcessServer.cs
+++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/InProcessServer.cs
@@ -29,6 +29,9 @@ using TestApp.AspNetCore._5._0;
#if NET6_0
using TestApp.AspNetCore._6._0;
#endif
+#if NET7_0
+using TestApp.AspNetCore._7._0;
+#endif
using Xunit.Abstractions;
namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj
index d410a3bf3..7fdd6109d 100644
--- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj
@@ -3,7 +3,7 @@
Unit test project for OpenTelemetry ASP.NET Core instrumentation for W3C Trace Context Trace
- net6.0
+ net7.0;net6.0
$(TARGET_FRAMEWORK)
@@ -33,6 +33,10 @@
+
+
+
+
From 0f0a96d31f99199d61b9bdff92d8cb3110d811f9 Mon Sep 17 00:00:00 2001
From: Vishwesh Bankwar
Date: Wed, 22 Jun 2022 12:10:42 -0700
Subject: [PATCH 4/6] add net7.0 for httpclient tests (#3389)
Co-authored-by: Cijo Thomas
---
.../OpenTelemetry.Instrumentation.Http.Tests.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj b/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj
index f5e6fdd3e..3b8c6bf69 100644
--- a/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj
+++ b/test/OpenTelemetry.Instrumentation.Http.Tests/OpenTelemetry.Instrumentation.Http.Tests.csproj
@@ -2,7 +2,7 @@
Unit test project for OpenTelemetry HTTP instrumentations
- net6.0
+ net7.0;net6.0
$(TargetFrameworks);net462
From e24677b8ea8492f0efc07b36b527d96a7567ed71 Mon Sep 17 00:00:00 2001
From: Vishwesh Bankwar
Date: Thu, 28 Jul 2022 07:50:03 -0700
Subject: [PATCH 5/6] [.NET7.0] AspNetCore ActivitySource Migration (#3391)
---
.../Implementation/HttpInListener.cs | 12 +++++
.../TracerProviderBuilderExtensions.cs | 34 +++++++++++--
.../BasicTests.cs | 48 ++++++++++++++++++-
3 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
index a37863ad8..75ada8991 100644
--- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
+++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
@@ -35,6 +35,10 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
internal class HttpInListener : ListenerHandler
{
internal const string ActivityOperationName = "Microsoft.AspNetCore.Hosting.HttpRequestIn";
+#if NET7_0_OR_GREATER
+ // https://github.com/dotnet/aspnetcore/blob/8d6554e655b64da75b71e0e20d6db54a3ba8d2fb/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs#L85
+ internal static readonly string AspNetCoreActivitySourceName = "Microsoft.AspNetCore";
+#endif
internal static readonly AssemblyName AssemblyName = typeof(HttpInListener).Assembly.GetName();
internal static readonly string ActivitySourceName = AssemblyName.Name;
internal static readonly Version Version = AssemblyName.Version;
@@ -96,8 +100,14 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
// Create a new activity with its parent set from the extracted context.
// This makes the new activity as a "sibling" of the activity created by
// Asp.Net Core.
+#if NET7_0_OR_GREATER
+ // For NET7.0 onwards activity is created using ActivitySource so,
+ // we will use the source of the activity to create the new one.
+ Activity newOne = activity.Source.CreateActivity(ActivityOperationName, ActivityKind.Server, ctx.ActivityContext);
+#else
Activity newOne = new Activity(ActivityOperationName);
newOne.SetParentId(ctx.ActivityContext.TraceId, ctx.ActivityContext.SpanId, ctx.ActivityContext.TraceFlags);
+#endif
newOne.TraceStateString = ctx.ActivityContext.TraceState;
newOne.SetTag("IsCreatedByInstrumentation", bool.TrueString);
@@ -135,8 +145,10 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
return;
}
+#if !NET7_0_OR_GREATER
ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource);
ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Server);
+#endif
var path = (request.PathBase.HasValue || request.Path.HasValue) ? (request.PathBase + request.Path).ToString() : "/";
activity.DisplayName = path;
diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs
index 8ff58d22c..2e2e4dfc2 100644
--- a/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs
+++ b/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs
@@ -15,6 +15,10 @@
//
using System;
+#if NET7_0_OR_GREATER
+using System.Diagnostics;
+using Microsoft.Extensions.DependencyInjection;
+#endif
using OpenTelemetry.Instrumentation.AspNetCore;
using OpenTelemetry.Instrumentation.AspNetCore.Implementation;
using OpenTelemetry.Internal;
@@ -42,7 +46,7 @@ namespace OpenTelemetry.Trace
{
return deferredTracerProviderBuilder.Configure((sp, builder) =>
{
- AddAspNetCoreInstrumentation(builder, sp.GetOptions(), configureAspNetCoreInstrumentationOptions);
+ AddAspNetCoreInstrumentation(builder, sp.GetOptions(), configureAspNetCoreInstrumentationOptions, sp);
});
}
@@ -51,22 +55,44 @@ namespace OpenTelemetry.Trace
internal static TracerProviderBuilder AddAspNetCoreInstrumentation(
this TracerProviderBuilder builder,
- AspNetCoreInstrumentation instrumentation)
+ AspNetCoreInstrumentation instrumentation,
+ IServiceProvider serviceProvider = null)
{
+ // For .NET7.0 onwards activity will be created using activitySource.
+ // https://github.com/dotnet/aspnetcore/blob/bf3352f2422bf16fa3ca49021f0e31961ce525eb/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs#L327
+ // For .NET6.0 and below, we will continue to use legacy way.
+#if NET7_0_OR_GREATER
+ // TODO: Check with .NET team to see if this can be prevented
+ // as this allows user to override the ActivitySource.
+ var activitySourceService = serviceProvider?.GetService();
+ if (activitySourceService != null)
+ {
+ builder.AddSource(activitySourceService.Name);
+ }
+ else
+ {
+ // For users not using hosting package?
+ builder.AddSource(HttpInListener.AspNetCoreActivitySourceName);
+ }
+#else
builder.AddSource(HttpInListener.ActivitySourceName);
builder.AddLegacySource(HttpInListener.ActivityOperationName); // for the activities created by AspNetCore
+#endif
+
return builder.AddInstrumentation(() => instrumentation);
}
private static TracerProviderBuilder AddAspNetCoreInstrumentation(
TracerProviderBuilder builder,
AspNetCoreInstrumentationOptions options,
- Action configure = null)
+ Action configure = null,
+ IServiceProvider serviceProvider = null)
{
configure?.Invoke(options);
return AddAspNetCoreInstrumentation(
builder,
- new AspNetCoreInstrumentation(new HttpInListener(options)));
+ new AspNetCoreInstrumentation(new HttpInListener(options)),
+ serviceProvider);
}
}
}
diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
index 90465e901..3ec92d2ce 100644
--- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
+++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
@@ -348,7 +348,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
var expectedTraceId = ActivityTraceId.CreateRandom();
var expectedParentSpanId = ActivitySpanId.CreateRandom();
var expectedTraceState = "rojo=1,congo=2";
- var activityContext = new ActivityContext(expectedTraceId, expectedParentSpanId, ActivityTraceFlags.Recorded, expectedTraceState);
+ var activityContext = new ActivityContext(expectedTraceId, expectedParentSpanId, ActivityTraceFlags.Recorded, expectedTraceState, true);
var expectedBaggage = Baggage.SetBaggage("key1", "value1").SetBaggage("key2", "value2");
Sdk.SetDefaultTextMapPropagator(new ExtractOnlyPropagator(activityContext, expectedBaggage));
@@ -586,6 +586,47 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
Assert.Equal(activityName, middlewareActivity.DisplayName);
}
+#if NET7_0_OR_GREATER
+ [Fact]
+ public async Task UserRegisteredActivitySourceIsUsedForActivityCreationByAspNetCore()
+ {
+ var exportedItems = new List();
+ void ConfigureTestServices(IServiceCollection services)
+ {
+ services.AddOpenTelemetryTracing(options =>
+ {
+ options.AddAspNetCoreInstrumentation()
+ .AddInMemoryExporter(exportedItems);
+ });
+
+ // Register ActivitySource here so that it will be used
+ // by ASP.NET Core to create activities
+ // https://github.com/dotnet/aspnetcore/blob/0e5cbf447d329a1e7d69932c3decd1c70a00fbba/src/Hosting/Hosting/src/Internal/WebHost.cs#L152
+ services.AddSingleton(sp => new ActivitySource("UserRegisteredActivitySource"));
+ }
+
+ // Arrange
+ using (var client = this.factory
+ .WithWebHostBuilder(builder =>
+ builder.ConfigureTestServices(ConfigureTestServices))
+ .CreateClient())
+ {
+ // Act
+ var response = await client.GetAsync("/api/values");
+
+ // Assert
+ response.EnsureSuccessStatusCode(); // Status Code 200-299
+
+ WaitForActivityExport(exportedItems, 1);
+ }
+
+ Assert.Single(exportedItems);
+ var activity = exportedItems[0];
+
+ Assert.Equal("UserRegisteredActivitySource", activity.Source.Name);
+ }
+#endif
+
public void Dispose()
{
this.tracerProvider?.Dispose();
@@ -608,8 +649,13 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
private static void ValidateAspNetCoreActivity(Activity activityToValidate, string expectedHttpPath)
{
Assert.Equal(ActivityKind.Server, activityToValidate.Kind);
+#if NET7_0_OR_GREATER
+ Assert.Equal(HttpInListener.AspNetCoreActivitySourceName, activityToValidate.Source.Name);
+ Assert.Empty(activityToValidate.Source.Version);
+#else
Assert.Equal(HttpInListener.ActivitySourceName, activityToValidate.Source.Name);
Assert.Equal(HttpInListener.Version.ToString(), activityToValidate.Source.Version);
+#endif
Assert.Equal(expectedHttpPath, activityToValidate.GetTagValue(SemanticConventions.AttributeHttpTarget) as string);
}
From 2b15b3dc13d07194642de4b3229f9e7777ea62fd Mon Sep 17 00:00:00 2001
From: Vishwesh Bankwar
Date: Wed, 3 Aug 2022 09:04:58 -0700
Subject: [PATCH 6/6] [.NET7.0] Http client activity source migration (#3415)
---
.../HttpClientInstrumentation.cs | 19 +++++++-
.../HttpHandlerDiagnosticListener.cs | 47 +++++++++++++++++--
.../TracerProviderBuilderExtensions.cs | 12 ++++-
3 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentation.cs b/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentation.cs
index 3eff73b71..09fc1f3c0 100644
--- a/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentation.cs
+++ b/src/OpenTelemetry.Instrumentation.Http/HttpClientInstrumentation.cs
@@ -25,13 +25,30 @@ namespace OpenTelemetry.Instrumentation.Http
{
private readonly DiagnosticSourceSubscriber diagnosticSourceSubscriber;
+ private readonly Func isEnabled = (activityName, obj1, obj2)
+ => !activityName.Equals("System.Net.Http.HttpRequestOut");
+
///
/// Initializes a new instance of the class.
///
/// Configuration options for HTTP client instrumentation.
public HttpClientInstrumentation(HttpClientInstrumentationOptions options)
{
- this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options), null);
+ // For .NET7.0 activity will be created using activitySource.
+ // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
+ // However, in case when activity creation returns null (due to sampling)
+ // the framework will fall back to creating activity anyways due to active diagnostic source listener
+ // To prevent this, isEnabled is implemented which will return false always
+ // so that the sampler's decision is respected.
+ if (HttpHandlerDiagnosticListener.IsNet7OrGreater)
+ {
+ this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options), this.isEnabled);
+ }
+ else
+ {
+ this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpHandlerDiagnosticListener(options), null);
+ }
+
this.diagnosticSourceSubscriber.Subscribe();
}
diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs
index 549537080..9f42f7a54 100644
--- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs
+++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs
@@ -28,6 +28,10 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
internal sealed class HttpHandlerDiagnosticListener : ListenerHandler
{
internal static readonly AssemblyName AssemblyName = typeof(HttpHandlerDiagnosticListener).Assembly.GetName();
+ internal static readonly bool IsNet7OrGreater;
+
+ // https://github.com/dotnet/runtime/blob/7d034ddbbbe1f2f40c264b323b3ed3d6b3d45e9a/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs#L19
+ internal static readonly string HttpClientActivitySourceName = "System.Net.Http";
internal static readonly string ActivitySourceName = AssemblyName.Name;
internal static readonly Version Version = AssemblyName.Version;
internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString());
@@ -40,6 +44,18 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
private readonly PropertyFetcher stopRequestStatusFetcher = new("RequestTaskStatus");
private readonly HttpClientInstrumentationOptions options;
+ static HttpHandlerDiagnosticListener()
+ {
+ try
+ {
+ IsNet7OrGreater = typeof(HttpClient).Assembly.GetName().Version.Major >= 7;
+ }
+ catch (Exception)
+ {
+ IsNet7OrGreater = false;
+ }
+ }
+
public HttpHandlerDiagnosticListener(HttpClientInstrumentationOptions options)
: base("HttpHandlerDiagnosticListener")
{
@@ -58,7 +74,11 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
// By this time, samplers have already run and
// activity.IsAllDataRequested populated accordingly.
- if (Sdk.SuppressInstrumentation)
+ // For .NET7.0 or higher versions, activity is created using activity source
+ // However, the framework will fallback to creating activity if the sampler's decision is to drop and there is a active diagnostic listener.
+ // To prevent processing such activities we first check the source name to confirm if it was created using
+ // activity source or not.
+ if (Sdk.SuppressInstrumentation || (IsNet7OrGreater && string.IsNullOrEmpty(activity.Source.Name)))
{
return;
}
@@ -108,8 +128,11 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method);
- ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource);
- ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Client);
+ if (!IsNet7OrGreater)
+ {
+ ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource);
+ ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Client);
+ }
activity.SetTag(SemanticConventions.AttributeHttpScheme, request.RequestUri.Scheme);
activity.SetTag(SemanticConventions.AttributeHttpMethod, HttpTagHelper.GetNameForHttpMethod(request.Method));
@@ -130,6 +153,15 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
public override void OnStopActivity(Activity activity, object payload)
{
+ // For .NET7.0 or higher versions, activity is created using activity source
+ // However, the framework will fallback to creating activity if the sampler's decision is to drop and there is a active diagnostic listener.
+ // To prevent processing such activities we first check the source name to confirm if it was created using
+ // activity source or not.
+ if (IsNet7OrGreater && string.IsNullOrEmpty(activity.Source.Name))
+ {
+ return;
+ }
+
if (activity.IsAllDataRequested)
{
// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
@@ -179,6 +211,15 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation
public override void OnException(Activity activity, object payload)
{
+ // For .NET7.0 or higher versions, activity is created using activity source
+ // However, the framework will fallback to creating activity if the sampler's decision is to drop and there is a active diagnostic listener.
+ // To prevent processing such activities we first check the source name to confirm if it was created using
+ // activity source or not.
+ if (IsNet7OrGreater && string.IsNullOrEmpty(activity.Source.Name))
+ {
+ return;
+ }
+
if (activity.IsAllDataRequested)
{
if (!this.stopExceptionFetcher.TryFetch(payload, out Exception exc) || exc == null)
diff --git a/src/OpenTelemetry.Instrumentation.Http/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.Http/TracerProviderBuilderExtensions.cs
index 78461551a..a71912a99 100644
--- a/src/OpenTelemetry.Instrumentation.Http/TracerProviderBuilderExtensions.cs
+++ b/src/OpenTelemetry.Instrumentation.Http/TracerProviderBuilderExtensions.cs
@@ -78,8 +78,16 @@ namespace OpenTelemetry.Trace
this TracerProviderBuilder builder,
HttpClientInstrumentation instrumentation)
{
- builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
- builder.AddLegacySource("System.Net.Http.HttpRequestOut");
+ if (HttpHandlerDiagnosticListener.IsNet7OrGreater)
+ {
+ builder.AddSource(HttpHandlerDiagnosticListener.HttpClientActivitySourceName);
+ }
+ else
+ {
+ builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
+ builder.AddLegacySource("System.Net.Http.HttpRequestOut");
+ }
+
return builder.AddInstrumentation(() => instrumentation);
}